mirror of
https://github.com/aykhans/AzSuicideDataVisualization.git
synced 2025-07-03 06:31:28 +00:00
Version 0.1
Added sidebar, Dashboard, Line Graph
This commit is contained in:
218
app/test.ipynb
218
app/test.ipynb
@ -2,16 +2,17 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 28,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd"
|
||||
"import pandas as pd\n",
|
||||
"import plotly.express as px"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -21,116 +22,131 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"data_age"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 42,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"test_male = [float(d[:d.find(' ')]) for d in data_year.Male]\n",
|
||||
"test_both = [float(d[:d.find(' ')]) for d in data_year.Both_sexes]\n",
|
||||
"test_female = [float(d[:d.find(' ')]) for d in data_year.Female]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 126,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df = pd.DataFrame({'Year': data_year.Year, 'Both sexes': test_both, 'Male': test_male, 'Female': test_female})"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 124,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df = pd.DataFrame({'Year': [1], 'Both sexes': [2], 'Male': [3], 'Female': [4]})"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 131,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>Age</th>\n",
|
||||
" <th>Both_sexes</th>\n",
|
||||
" <th>Male</th>\n",
|
||||
" <th>Female</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>85+</td>\n",
|
||||
" <td>23.97</td>\n",
|
||||
" <td>38.35</td>\n",
|
||||
" <td>16.87</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>75-84</td>\n",
|
||||
" <td>10.40</td>\n",
|
||||
" <td>15.22</td>\n",
|
||||
" <td>7.36</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>65-74</td>\n",
|
||||
" <td>6.82</td>\n",
|
||||
" <td>10.93</td>\n",
|
||||
" <td>3.57</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>55-64</td>\n",
|
||||
" <td>5.70</td>\n",
|
||||
" <td>9.50</td>\n",
|
||||
" <td>2.35</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>45-54</td>\n",
|
||||
" <td>5.25</td>\n",
|
||||
" <td>9.14</td>\n",
|
||||
" <td>1.73</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>5</th>\n",
|
||||
" <td>35-44</td>\n",
|
||||
" <td>5.42</td>\n",
|
||||
" <td>9.42</td>\n",
|
||||
" <td>1.50</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>6</th>\n",
|
||||
" <td>25-34</td>\n",
|
||||
" <td>4.89</td>\n",
|
||||
" <td>8.43</td>\n",
|
||||
" <td>1.36</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>7</th>\n",
|
||||
" <td>15-24</td>\n",
|
||||
" <td>4.00</td>\n",
|
||||
" <td>6.38</td>\n",
|
||||
" <td>1.34</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" Age Both_sexes Male Female\n",
|
||||
"0 85+ 23.97 38.35 16.87\n",
|
||||
"1 75-84 10.40 15.22 7.36\n",
|
||||
"2 65-74 6.82 10.93 3.57\n",
|
||||
"3 55-64 5.70 9.50 2.35\n",
|
||||
"4 45-54 5.25 9.14 1.73\n",
|
||||
"5 35-44 5.42 9.42 1.50\n",
|
||||
"6 25-34 4.89 8.43 1.36\n",
|
||||
"7 15-24 4.00 6.38 1.34"
|
||||
"Index(['', 'Male', 'Female'], dtype='object')"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"execution_count": 131,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"data_age"
|
||||
"pd.Index(['Both sexes' if 0 else '', 'Male', 'Female'])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 133,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"a\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"if [0]:\n",
|
||||
" print('a')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 118,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"g = px.line(df, x='Year', y=df.columns[1:])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 119,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Figure({\n",
|
||||
" 'data': [],\n",
|
||||
" 'layout': {'legend': {'tracegroupgap': 0},\n",
|
||||
" 'margin': {'t': 60},\n",
|
||||
" 'template': '...',\n",
|
||||
" 'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'Year'}},\n",
|
||||
" 'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'value'}}}\n",
|
||||
"})\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(g)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 88,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"5.0"
|
||||
]
|
||||
},
|
||||
"execution_count": 88,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"10 / (2 if 1 else 10)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user