Skip to content

Commit

Permalink
vary examples a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeGermuska committed May 9, 2015
1 parent 9b9ad38 commit 7f983f0
Showing 1 changed file with 85 additions and 69 deletions.
154 changes: 85 additions & 69 deletions Basic Census Reporter API with Pandas.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"df = get_dataframe(column_names=True,level=1)"
"df = get_dataframe(tables='B01001',geoids='040|01000US',column_names=True,level=1)"
]
},
{
Expand Down Expand Up @@ -119,7 +119,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Top 5 States by Female Population"
"## Top 5 States in Midwest Region by % Female Population"
]
},
{
Expand All @@ -141,55 +141,61 @@
" <th>Total</th>\n",
" <th>Male</th>\n",
" <th>Female</th>\n",
" <th>pct_female</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>04000US06</th>\n",
" <td>California</td>\n",
" <td>38332521</td>\n",
" <td>19072246</td>\n",
" <td>19260275</td>\n",
" <th>04000US47</th>\n",
" <td>Tennessee</td>\n",
" <td>6495978</td>\n",
" <td>3174148</td>\n",
" <td>3321830</td>\n",
" <td>0.511367</td>\n",
" </tr>\n",
" <tr>\n",
" <th>04000US48</th>\n",
" <td>Texas</td>\n",
" <td>26448193</td>\n",
" <td>13145494</td>\n",
" <td>13302699</td>\n",
" <th>04000US42</th>\n",
" <td>Pennsylvania</td>\n",
" <td>12773801</td>\n",
" <td>6243308</td>\n",
" <td>6530493</td>\n",
" <td>0.511241</td>\n",
" </tr>\n",
" <tr>\n",
" <th>04000US36</th>\n",
" <td>New York</td>\n",
" <td>19651127</td>\n",
" <td>9536179</td>\n",
" <td>10114948</td>\n",
" <th>04000US39</th>\n",
" <td>Ohio</td>\n",
" <td>11570808</td>\n",
" <td>5658223</td>\n",
" <td>5912585</td>\n",
" <td>0.510992</td>\n",
" </tr>\n",
" <tr>\n",
" <th>04000US12</th>\n",
" <td>Florida</td>\n",
" <td>19552860</td>\n",
" <td>9565609</td>\n",
" <td>9987251</td>\n",
" <th>04000US29</th>\n",
" <td>Missouri</td>\n",
" <td>6044171</td>\n",
" <td>2960402</td>\n",
" <td>3083769</td>\n",
" <td>0.510205</td>\n",
" </tr>\n",
" <tr>\n",
" <th>04000US17</th>\n",
" <td>Illinois</td>\n",
" <td>12882135</td>\n",
" <td>6326778</td>\n",
" <td>6555357</td>\n",
" <th>04000US26</th>\n",
" <td>Michigan</td>\n",
" <td>9895622</td>\n",
" <td>4858138</td>\n",
" <td>5037484</td>\n",
" <td>0.509062</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" name Total Male Female\n",
"04000US06 California 38332521 19072246 19260275\n",
"04000US48 Texas 26448193 13145494 13302699\n",
"04000US36 New York 19651127 9536179 10114948\n",
"04000US12 Florida 19552860 9565609 9987251\n",
"04000US17 Illinois 12882135 6326778 6555357"
" name Total Male Female pct_female\n",
"04000US47 Tennessee 6495978 3174148 3321830 0.511367\n",
"04000US42 Pennsylvania 12773801 6243308 6530493 0.511241\n",
"04000US39 Ohio 11570808 5658223 5912585 0.510992\n",
"04000US29 Missouri 6044171 2960402 3083769 0.510205\n",
"04000US26 Michigan 9895622 4858138 5037484 0.509062"
]
},
"execution_count": 4,
Expand All @@ -198,19 +204,21 @@
}
],
"source": [
"df.sort('Female',ascending=False).head(5)"
"df = get_dataframe(tables='B01001',geoids='040|02000US2',column_names=True,level=1)\n",
"df['pct_female'] = df['Female'] / df['Total']\n",
"df.sort('pct_female',ascending=False).head(5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Top 5 States by Male Population"
"## Top 5 Tennesse Counties by % Male Population"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {
"collapsed": false
},
Expand All @@ -227,64 +235,72 @@
" <th>Total</th>\n",
" <th>Male</th>\n",
" <th>Female</th>\n",
" <th>pct_male</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>04000US06</th>\n",
" <td>California</td>\n",
" <td>38332521</td>\n",
" <td>19072246</td>\n",
" <td>19260275</td>\n",
" <th>05000US47095</th>\n",
" <td>Lake County, TN</td>\n",
" <td>7773</td>\n",
" <td>4897</td>\n",
" <td>2876</td>\n",
" <td>0.630001</td>\n",
" </tr>\n",
" <tr>\n",
" <th>04000US48</th>\n",
" <td>Texas</td>\n",
" <td>26448193</td>\n",
" <td>13145494</td>\n",
" <td>13302699</td>\n",
" <th>05000US47129</th>\n",
" <td>Morgan County, TN</td>\n",
" <td>21964</td>\n",
" <td>12126</td>\n",
" <td>9838</td>\n",
" <td>0.552085</td>\n",
" </tr>\n",
" <tr>\n",
" <th>04000US12</th>\n",
" <td>Florida</td>\n",
" <td>19552860</td>\n",
" <td>9565609</td>\n",
" <td>9987251</td>\n",
" <th>05000US47181</th>\n",
" <td>Wayne County, TN</td>\n",
" <td>16996</td>\n",
" <td>9370</td>\n",
" <td>7626</td>\n",
" <td>0.551306</td>\n",
" </tr>\n",
" <tr>\n",
" <th>04000US36</th>\n",
" <td>New York</td>\n",
" <td>19651127</td>\n",
" <td>9536179</td>\n",
" <td>10114948</td>\n",
" <th>05000US47069</th>\n",
" <td>Hardeman County, TN</td>\n",
" <td>26897</td>\n",
" <td>14670</td>\n",
" <td>12227</td>\n",
" <td>0.545414</td>\n",
" </tr>\n",
" <tr>\n",
" <th>04000US17</th>\n",
" <td>Illinois</td>\n",
" <td>12882135</td>\n",
" <td>6326778</td>\n",
" <td>6555357</td>\n",
" <th>05000US47007</th>\n",
" <td>Bledsoe County, TN</td>\n",
" <td>12853</td>\n",
" <td>6951</td>\n",
" <td>5902</td>\n",
" <td>0.540808</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" name Total Male Female\n",
"04000US06 California 38332521 19072246 19260275\n",
"04000US48 Texas 26448193 13145494 13302699\n",
"04000US12 Florida 19552860 9565609 9987251\n",
"04000US36 New York 19651127 9536179 10114948\n",
"04000US17 Illinois 12882135 6326778 6555357"
" name Total Male Female pct_male\n",
"05000US47095 Lake County, TN 7773 4897 2876 0.630001\n",
"05000US47129 Morgan County, TN 21964 12126 9838 0.552085\n",
"05000US47181 Wayne County, TN 16996 9370 7626 0.551306\n",
"05000US47069 Hardeman County, TN 26897 14670 12227 0.545414\n",
"05000US47007 Bledsoe County, TN 12853 6951 5902 0.540808"
]
},
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.sort('Male',ascending=False).head(5)"
"df = get_dataframe(tables='B01001',geoids='050|04000US47',column_names=True,level=1)\n",
"df['pct_male'] = df['Male'] / df['Total']\n",
"df.sort('pct_male',ascending=False).head(5)"
]
}
],
Expand Down

0 comments on commit 7f983f0

Please sign in to comment.