Skip to content

Instantly share code, notes, and snippets.

@triestpa

triestpa/classsexagg.ipynb Secret

Created Jun 7, 2016
Embed
What would you like to do?
class-sex-agg
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>survived</th>\n",
" <th>age</th>\n",
" <th>sibsp</th>\n",
" <th>parch</th>\n",
" <th>fare</th>\n",
" <th>body</th>\n",
" </tr>\n",
" <tr>\n",
" <th>pclass</th>\n",
" <th>sex</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 rowspan=\"2\" valign=\"top\">1</th>\n",
" <th>female</th>\n",
" <td>0.965278</td>\n",
" <td>37.037594</td>\n",
" <td>0.555556</td>\n",
" <td>0.472222</td>\n",
" <td>109.412385</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>male</th>\n",
" <td>0.340782</td>\n",
" <td>41.029250</td>\n",
" <td>0.340782</td>\n",
" <td>0.279330</td>\n",
" <td>69.888385</td>\n",
" <td>162.828571</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"2\" valign=\"top\">2</th>\n",
" <th>female</th>\n",
" <td>0.886792</td>\n",
" <td>27.499191</td>\n",
" <td>0.500000</td>\n",
" <td>0.650943</td>\n",
" <td>23.234827</td>\n",
" <td>52.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>male</th>\n",
" <td>0.146199</td>\n",
" <td>30.815401</td>\n",
" <td>0.327485</td>\n",
" <td>0.192982</td>\n",
" <td>19.904946</td>\n",
" <td>171.233333</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"2\" valign=\"top\">3</th>\n",
" <th>female</th>\n",
" <td>0.490741</td>\n",
" <td>22.185307</td>\n",
" <td>0.791667</td>\n",
" <td>0.731481</td>\n",
" <td>15.324250</td>\n",
" <td>183.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>male</th>\n",
" <td>0.152130</td>\n",
" <td>25.962273</td>\n",
" <td>0.470588</td>\n",
" <td>0.255578</td>\n",
" <td>12.415462</td>\n",
" <td>151.854167</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" survived age sibsp parch fare body\n",
"pclass sex \n",
"1 female 0.965278 37.037594 0.555556 0.472222 109.412385 NaN\n",
" male 0.340782 41.029250 0.340782 0.279330 69.888385 162.828571\n",
"2 female 0.886792 27.499191 0.500000 0.650943 23.234827 52.000000\n",
" male 0.146199 30.815401 0.327485 0.192982 19.904946 171.233333\n",
"3 female 0.490741 22.185307 0.791667 0.731481 15.324250 183.000000\n",
" male 0.152130 25.962273 0.470588 0.255578 12.415462 151.854167"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"class_sex_grouping = titanic_df.groupby(['pclass','sex']).mean()\n",
"class_sex_grouping"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x1115ff400>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXEAAAE8CAYAAAA2QYEWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFrRJREFUeJzt3Xu0pXV93/H3h5soCDaYMgrCWIRaKKBGCV4aDxIFTHSS\nJlEgtUu6TGkbYtJ0NUCTlGmiMdrVxogrNdgpLCJIXDEXpFoxll2rYYBwE5Th4gVhuC1jrBc0DPjt\nH3sPHg9nztnMec559u+Z92utvTj72b+9n+/D9+zPPOe5pqqQJLVpt74LkC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5n/2CyX/3B34f\n+DHggCQ/08X/BGk+Q1wtuR34xSSfZ7yZ5HzgjcD5SW4CrgSesuA97wJ+N8n1/ODv+xuS3DrZBHIU\ncDFwNHDtZNp/ZLwWz2T6A5Nt5x9IcjNwPfD7VfWNybg9JztDbwV+a/K+/wqcX1V3AW8B3pFk+7VF\npE64Y1NNmOzYvGKyWWSt5/2xqjplrecrTcM1cbWklzUOA1yzzDVxSWqYa+KS1DBDXJIaZohLUsMM\ncUlqmCEuSQ0zxCWpYf8fgoR1XzcV6TgAAAAASUVORK5CYII=\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x1115ffc88>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"class_sex_grouping['survived'].plot.bar()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment