Skip to content

Commit

Permalink
add current activity levels
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer Graham committed Jul 29, 2020
1 parent 2850c43 commit 33860df
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions exercise-research/exercise-research.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,47 @@
"source": [
"# Analysis\n",
"\n",
"## Research Question 0: How often do people do each exercise type? Number of respondents"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"tags": []
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "Total respondents: 44\n"
},
{
"output_type": "execute_result",
"data": {
"text/plain": " Never Less than once a month 1-3 times a month Once a week \\\nvariable \ncurrent_bike 17.0 7.0 4.0 8.0 \ncurrent_run 15.0 8.0 6.0 5.0 \ncurrent_swim 26.0 11.0 2.0 1.0 \ncurrent_walk 4.0 0.0 0.0 9.0 \n\n More than once a week | At least once a month \nvariable \ncurrent_bike 8.0 | 20.0 \ncurrent_run 10.0 | 21.0 \ncurrent_swim 4.0 | 7.0 \ncurrent_walk 31.0 | 40.0 ",
"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>Never</th>\n <th>Less than once a month</th>\n <th>1-3 times a month</th>\n <th>Once a week</th>\n <th>More than once a week</th>\n <th>|</th>\n <th>At least once a month</th>\n </tr>\n <tr>\n <th>variable</th>\n <th></th>\n <th></th>\n <th></th>\n <th></th>\n <th></th>\n <th></th>\n <th></th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>current_bike</th>\n <td>17.0</td>\n <td>7.0</td>\n <td>4.0</td>\n <td>8.0</td>\n <td>8.0</td>\n <td>|</td>\n <td>20.0</td>\n </tr>\n <tr>\n <th>current_run</th>\n <td>15.0</td>\n <td>8.0</td>\n <td>6.0</td>\n <td>5.0</td>\n <td>10.0</td>\n <td>|</td>\n <td>21.0</td>\n </tr>\n <tr>\n <th>current_swim</th>\n <td>26.0</td>\n <td>11.0</td>\n <td>2.0</td>\n <td>1.0</td>\n <td>4.0</td>\n <td>|</td>\n <td>7.0</td>\n </tr>\n <tr>\n <th>current_walk</th>\n <td>4.0</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>9.0</td>\n <td>31.0</td>\n <td>|</td>\n <td>40.0</td>\n </tr>\n </tbody>\n</table>\n</div>"
},
"metadata": {},
"execution_count": 27
}
],
"source": [
"melted = pd.melt(df.filter(like = 'current', axis = 1))\n",
"melted = melted.groupby(['variable', 'value']).size().to_frame('size').reset_index()\n",
"# melted['prop'] = melted['size'] / len(df)\n",
"current = melted.pivot(index = 'variable', columns = 'value', values = 'size').fillna(0)\n",
"current.columns = ['Never', 'Less than once a month', '1-3 times a month', 'Once a week','More than once a week']\n",
"current['|'] = '|'\n",
"current['At least once a month'] = current['1-3 times a month'] + current['Once a week'] + current['More than once a week']\n",
"print('Total respondents:', len(df))\n",
"current"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Research Question 1: For which type of exercise are people least satisfied with their level of activity?"
]
},
Expand Down

0 comments on commit 33860df

Please sign in to comment.