6214 lines
188 KiB
Plaintext
6214 lines
188 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 1,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import numpy as np\n",
|
||
"\n",
|
||
"import pandas as pd\n",
|
||
"\n",
|
||
"from pandas import Series,DataFrame"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"# csv类型文件呢,文本文件,excel打开,格式化的文件,所以excel可以直接读取成表格\n",
|
||
"# 美国人口的一些情况\n",
|
||
"# pandas分析一下美国人口数据"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 2,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"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>state</th>\n",
|
||
" <th>area (sq. mi)</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>Alaska</td>\n",
|
||
" <td>656425</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>Arizona</td>\n",
|
||
" <td>114006</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>Arkansas</td>\n",
|
||
" <td>53182</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>California</td>\n",
|
||
" <td>163707</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>5</th>\n",
|
||
" <td>Colorado</td>\n",
|
||
" <td>104100</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>6</th>\n",
|
||
" <td>Connecticut</td>\n",
|
||
" <td>5544</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>7</th>\n",
|
||
" <td>Delaware</td>\n",
|
||
" <td>1954</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>8</th>\n",
|
||
" <td>Florida</td>\n",
|
||
" <td>65758</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>9</th>\n",
|
||
" <td>Georgia</td>\n",
|
||
" <td>59441</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>10</th>\n",
|
||
" <td>Hawaii</td>\n",
|
||
" <td>10932</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>11</th>\n",
|
||
" <td>Idaho</td>\n",
|
||
" <td>83574</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>12</th>\n",
|
||
" <td>Illinois</td>\n",
|
||
" <td>57918</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>13</th>\n",
|
||
" <td>Indiana</td>\n",
|
||
" <td>36420</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>14</th>\n",
|
||
" <td>Iowa</td>\n",
|
||
" <td>56276</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>15</th>\n",
|
||
" <td>Kansas</td>\n",
|
||
" <td>82282</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>16</th>\n",
|
||
" <td>Kentucky</td>\n",
|
||
" <td>40411</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>17</th>\n",
|
||
" <td>Louisiana</td>\n",
|
||
" <td>51843</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>18</th>\n",
|
||
" <td>Maine</td>\n",
|
||
" <td>35387</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>19</th>\n",
|
||
" <td>Maryland</td>\n",
|
||
" <td>12407</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>20</th>\n",
|
||
" <td>Massachusetts</td>\n",
|
||
" <td>10555</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>21</th>\n",
|
||
" <td>Michigan</td>\n",
|
||
" <td>96810</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>22</th>\n",
|
||
" <td>Minnesota</td>\n",
|
||
" <td>86943</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>23</th>\n",
|
||
" <td>Mississippi</td>\n",
|
||
" <td>48434</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>24</th>\n",
|
||
" <td>Missouri</td>\n",
|
||
" <td>69709</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>25</th>\n",
|
||
" <td>Montana</td>\n",
|
||
" <td>147046</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>26</th>\n",
|
||
" <td>Nebraska</td>\n",
|
||
" <td>77358</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>27</th>\n",
|
||
" <td>Nevada</td>\n",
|
||
" <td>110567</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>28</th>\n",
|
||
" <td>New Hampshire</td>\n",
|
||
" <td>9351</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>29</th>\n",
|
||
" <td>New Jersey</td>\n",
|
||
" <td>8722</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>30</th>\n",
|
||
" <td>New Mexico</td>\n",
|
||
" <td>121593</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>31</th>\n",
|
||
" <td>New York</td>\n",
|
||
" <td>54475</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>32</th>\n",
|
||
" <td>North Carolina</td>\n",
|
||
" <td>53821</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>33</th>\n",
|
||
" <td>North Dakota</td>\n",
|
||
" <td>70704</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>34</th>\n",
|
||
" <td>Ohio</td>\n",
|
||
" <td>44828</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>35</th>\n",
|
||
" <td>Oklahoma</td>\n",
|
||
" <td>69903</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>36</th>\n",
|
||
" <td>Oregon</td>\n",
|
||
" <td>98386</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>37</th>\n",
|
||
" <td>Pennsylvania</td>\n",
|
||
" <td>46058</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>38</th>\n",
|
||
" <td>Rhode Island</td>\n",
|
||
" <td>1545</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>39</th>\n",
|
||
" <td>South Carolina</td>\n",
|
||
" <td>32007</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>40</th>\n",
|
||
" <td>South Dakota</td>\n",
|
||
" <td>77121</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>41</th>\n",
|
||
" <td>Tennessee</td>\n",
|
||
" <td>42146</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>42</th>\n",
|
||
" <td>Texas</td>\n",
|
||
" <td>268601</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>43</th>\n",
|
||
" <td>Utah</td>\n",
|
||
" <td>84904</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>44</th>\n",
|
||
" <td>Vermont</td>\n",
|
||
" <td>9615</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>45</th>\n",
|
||
" <td>Virginia</td>\n",
|
||
" <td>42769</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>46</th>\n",
|
||
" <td>Washington</td>\n",
|
||
" <td>71303</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>47</th>\n",
|
||
" <td>West Virginia</td>\n",
|
||
" <td>24231</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>48</th>\n",
|
||
" <td>Wisconsin</td>\n",
|
||
" <td>65503</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>49</th>\n",
|
||
" <td>Wyoming</td>\n",
|
||
" <td>97818</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>50</th>\n",
|
||
" <td>District of Columbia</td>\n",
|
||
" <td>68</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>51</th>\n",
|
||
" <td>Puerto Rico</td>\n",
|
||
" <td>3515</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state area (sq. mi)\n",
|
||
"0 Alabama 52423\n",
|
||
"1 Alaska 656425\n",
|
||
"2 Arizona 114006\n",
|
||
"3 Arkansas 53182\n",
|
||
"4 California 163707\n",
|
||
"5 Colorado 104100\n",
|
||
"6 Connecticut 5544\n",
|
||
"7 Delaware 1954\n",
|
||
"8 Florida 65758\n",
|
||
"9 Georgia 59441\n",
|
||
"10 Hawaii 10932\n",
|
||
"11 Idaho 83574\n",
|
||
"12 Illinois 57918\n",
|
||
"13 Indiana 36420\n",
|
||
"14 Iowa 56276\n",
|
||
"15 Kansas 82282\n",
|
||
"16 Kentucky 40411\n",
|
||
"17 Louisiana 51843\n",
|
||
"18 Maine 35387\n",
|
||
"19 Maryland 12407\n",
|
||
"20 Massachusetts 10555\n",
|
||
"21 Michigan 96810\n",
|
||
"22 Minnesota 86943\n",
|
||
"23 Mississippi 48434\n",
|
||
"24 Missouri 69709\n",
|
||
"25 Montana 147046\n",
|
||
"26 Nebraska 77358\n",
|
||
"27 Nevada 110567\n",
|
||
"28 New Hampshire 9351\n",
|
||
"29 New Jersey 8722\n",
|
||
"30 New Mexico 121593\n",
|
||
"31 New York 54475\n",
|
||
"32 North Carolina 53821\n",
|
||
"33 North Dakota 70704\n",
|
||
"34 Ohio 44828\n",
|
||
"35 Oklahoma 69903\n",
|
||
"36 Oregon 98386\n",
|
||
"37 Pennsylvania 46058\n",
|
||
"38 Rhode Island 1545\n",
|
||
"39 South Carolina 32007\n",
|
||
"40 South Dakota 77121\n",
|
||
"41 Tennessee 42146\n",
|
||
"42 Texas 268601\n",
|
||
"43 Utah 84904\n",
|
||
"44 Vermont 9615\n",
|
||
"45 Virginia 42769\n",
|
||
"46 Washington 71303\n",
|
||
"47 West Virginia 24231\n",
|
||
"48 Wisconsin 65503\n",
|
||
"49 Wyoming 97818\n",
|
||
"50 District of Columbia 68\n",
|
||
"51 Puerto Rico 3515"
|
||
]
|
||
},
|
||
"execution_count": 2,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"# 美国各州的面积\n",
|
||
"areas = pd.read_csv('./state-areas.csv')\n",
|
||
"areas"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 4,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"(52, 2)"
|
||
]
|
||
},
|
||
"execution_count": 4,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"areas.shape"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 3,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"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>state</th>\n",
|
||
" <th>abbreviation</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>AL</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>Alaska</td>\n",
|
||
" <td>AK</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>Arizona</td>\n",
|
||
" <td>AZ</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>Arkansas</td>\n",
|
||
" <td>AR</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>California</td>\n",
|
||
" <td>CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>5</th>\n",
|
||
" <td>Colorado</td>\n",
|
||
" <td>CO</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>6</th>\n",
|
||
" <td>Connecticut</td>\n",
|
||
" <td>CT</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>7</th>\n",
|
||
" <td>Delaware</td>\n",
|
||
" <td>DE</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>8</th>\n",
|
||
" <td>District of Columbia</td>\n",
|
||
" <td>DC</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>9</th>\n",
|
||
" <td>Florida</td>\n",
|
||
" <td>FL</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>10</th>\n",
|
||
" <td>Georgia</td>\n",
|
||
" <td>GA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>11</th>\n",
|
||
" <td>Hawaii</td>\n",
|
||
" <td>HI</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>12</th>\n",
|
||
" <td>Idaho</td>\n",
|
||
" <td>ID</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>13</th>\n",
|
||
" <td>Illinois</td>\n",
|
||
" <td>IL</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>14</th>\n",
|
||
" <td>Indiana</td>\n",
|
||
" <td>IN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>15</th>\n",
|
||
" <td>Iowa</td>\n",
|
||
" <td>IA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>16</th>\n",
|
||
" <td>Kansas</td>\n",
|
||
" <td>KS</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>17</th>\n",
|
||
" <td>Kentucky</td>\n",
|
||
" <td>KY</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>18</th>\n",
|
||
" <td>Louisiana</td>\n",
|
||
" <td>LA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>19</th>\n",
|
||
" <td>Maine</td>\n",
|
||
" <td>ME</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>20</th>\n",
|
||
" <td>Montana</td>\n",
|
||
" <td>MT</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>21</th>\n",
|
||
" <td>Nebraska</td>\n",
|
||
" <td>NE</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>22</th>\n",
|
||
" <td>Nevada</td>\n",
|
||
" <td>NV</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>23</th>\n",
|
||
" <td>New Hampshire</td>\n",
|
||
" <td>NH</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>24</th>\n",
|
||
" <td>New Jersey</td>\n",
|
||
" <td>NJ</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>25</th>\n",
|
||
" <td>New Mexico</td>\n",
|
||
" <td>NM</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>26</th>\n",
|
||
" <td>New York</td>\n",
|
||
" <td>NY</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>27</th>\n",
|
||
" <td>North Carolina</td>\n",
|
||
" <td>NC</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>28</th>\n",
|
||
" <td>North Dakota</td>\n",
|
||
" <td>ND</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>29</th>\n",
|
||
" <td>Ohio</td>\n",
|
||
" <td>OH</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>30</th>\n",
|
||
" <td>Oklahoma</td>\n",
|
||
" <td>OK</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>31</th>\n",
|
||
" <td>Oregon</td>\n",
|
||
" <td>OR</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>32</th>\n",
|
||
" <td>Maryland</td>\n",
|
||
" <td>MD</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>33</th>\n",
|
||
" <td>Massachusetts</td>\n",
|
||
" <td>MA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>34</th>\n",
|
||
" <td>Michigan</td>\n",
|
||
" <td>MI</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>35</th>\n",
|
||
" <td>Minnesota</td>\n",
|
||
" <td>MN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>36</th>\n",
|
||
" <td>Mississippi</td>\n",
|
||
" <td>MS</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>37</th>\n",
|
||
" <td>Missouri</td>\n",
|
||
" <td>MO</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>38</th>\n",
|
||
" <td>Pennsylvania</td>\n",
|
||
" <td>PA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>39</th>\n",
|
||
" <td>Rhode Island</td>\n",
|
||
" <td>RI</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>40</th>\n",
|
||
" <td>South Carolina</td>\n",
|
||
" <td>SC</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>41</th>\n",
|
||
" <td>South Dakota</td>\n",
|
||
" <td>SD</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>42</th>\n",
|
||
" <td>Tennessee</td>\n",
|
||
" <td>TN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>43</th>\n",
|
||
" <td>Texas</td>\n",
|
||
" <td>TX</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>44</th>\n",
|
||
" <td>Utah</td>\n",
|
||
" <td>UT</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>45</th>\n",
|
||
" <td>Vermont</td>\n",
|
||
" <td>VT</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>46</th>\n",
|
||
" <td>Virginia</td>\n",
|
||
" <td>VA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>47</th>\n",
|
||
" <td>Washington</td>\n",
|
||
" <td>WA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>48</th>\n",
|
||
" <td>West Virginia</td>\n",
|
||
" <td>WV</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>49</th>\n",
|
||
" <td>Wisconsin</td>\n",
|
||
" <td>WI</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>50</th>\n",
|
||
" <td>Wyoming</td>\n",
|
||
" <td>WY</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state abbreviation\n",
|
||
"0 Alabama AL\n",
|
||
"1 Alaska AK\n",
|
||
"2 Arizona AZ\n",
|
||
"3 Arkansas AR\n",
|
||
"4 California CA\n",
|
||
"5 Colorado CO\n",
|
||
"6 Connecticut CT\n",
|
||
"7 Delaware DE\n",
|
||
"8 District of Columbia DC\n",
|
||
"9 Florida FL\n",
|
||
"10 Georgia GA\n",
|
||
"11 Hawaii HI\n",
|
||
"12 Idaho ID\n",
|
||
"13 Illinois IL\n",
|
||
"14 Indiana IN\n",
|
||
"15 Iowa IA\n",
|
||
"16 Kansas KS\n",
|
||
"17 Kentucky KY\n",
|
||
"18 Louisiana LA\n",
|
||
"19 Maine ME\n",
|
||
"20 Montana MT\n",
|
||
"21 Nebraska NE\n",
|
||
"22 Nevada NV\n",
|
||
"23 New Hampshire NH\n",
|
||
"24 New Jersey NJ\n",
|
||
"25 New Mexico NM\n",
|
||
"26 New York NY\n",
|
||
"27 North Carolina NC\n",
|
||
"28 North Dakota ND\n",
|
||
"29 Ohio OH\n",
|
||
"30 Oklahoma OK\n",
|
||
"31 Oregon OR\n",
|
||
"32 Maryland MD\n",
|
||
"33 Massachusetts MA\n",
|
||
"34 Michigan MI\n",
|
||
"35 Minnesota MN\n",
|
||
"36 Mississippi MS\n",
|
||
"37 Missouri MO\n",
|
||
"38 Pennsylvania PA\n",
|
||
"39 Rhode Island RI\n",
|
||
"40 South Carolina SC\n",
|
||
"41 South Dakota SD\n",
|
||
"42 Tennessee TN\n",
|
||
"43 Texas TX\n",
|
||
"44 Utah UT\n",
|
||
"45 Vermont VT\n",
|
||
"46 Virginia VA\n",
|
||
"47 Washington WA\n",
|
||
"48 West Virginia WV\n",
|
||
"49 Wisconsin WI\n",
|
||
"50 Wyoming WY"
|
||
]
|
||
},
|
||
"execution_count": 3,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"# 美国各州 缩写\n",
|
||
"abbrevs = pd.read_csv('./state-abbrevs.csv')\n",
|
||
"abbrevs"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 5,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"(51, 2)"
|
||
]
|
||
},
|
||
"execution_count": 5,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"abbrevs.shape"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 6,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"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>state/region</th>\n",
|
||
" <th>ages</th>\n",
|
||
" <th>year</th>\n",
|
||
" <th>population</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1117489.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4817528.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>1130966.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>4785570.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>1125763.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>5</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>4801627.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>6</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2009</td>\n",
|
||
" <td>4757938.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>7</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2009</td>\n",
|
||
" <td>1134192.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>8</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2013</td>\n",
|
||
" <td>1111481.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>9</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2013</td>\n",
|
||
" <td>4833722.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>10</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2007</td>\n",
|
||
" <td>4672840.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>11</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2007</td>\n",
|
||
" <td>1132296.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>12</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2008</td>\n",
|
||
" <td>4718206.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>13</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2008</td>\n",
|
||
" <td>1134927.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>14</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2005</td>\n",
|
||
" <td>4569805.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>15</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2005</td>\n",
|
||
" <td>1117229.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>16</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2006</td>\n",
|
||
" <td>4628981.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>17</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2006</td>\n",
|
||
" <td>1126798.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>18</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2004</td>\n",
|
||
" <td>4530729.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>19</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2004</td>\n",
|
||
" <td>1113662.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>20</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2003</td>\n",
|
||
" <td>4503491.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>21</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2003</td>\n",
|
||
" <td>1113083.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>22</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2001</td>\n",
|
||
" <td>4467634.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>23</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2001</td>\n",
|
||
" <td>1120409.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>24</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2002</td>\n",
|
||
" <td>4480089.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>25</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2002</td>\n",
|
||
" <td>1116590.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>26</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>1999</td>\n",
|
||
" <td>1121287.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>27</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>1999</td>\n",
|
||
" <td>4430141.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>28</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2000</td>\n",
|
||
" <td>4452173.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>29</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2000</td>\n",
|
||
" <td>1122273.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>...</th>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2514</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>1999</td>\n",
|
||
" <td>71946051.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2515</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2000</td>\n",
|
||
" <td>282162411.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2516</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2000</td>\n",
|
||
" <td>72376189.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2517</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>1999</td>\n",
|
||
" <td>279040181.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2518</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2001</td>\n",
|
||
" <td>284968955.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2519</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2001</td>\n",
|
||
" <td>72671175.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2520</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2002</td>\n",
|
||
" <td>287625193.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2521</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2002</td>\n",
|
||
" <td>72936457.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2522</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2003</td>\n",
|
||
" <td>290107933.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2523</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2003</td>\n",
|
||
" <td>73100758.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2524</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2004</td>\n",
|
||
" <td>292805298.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2525</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2004</td>\n",
|
||
" <td>73297735.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2526</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2005</td>\n",
|
||
" <td>295516599.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2527</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2005</td>\n",
|
||
" <td>73523669.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2528</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2006</td>\n",
|
||
" <td>298379912.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2529</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2006</td>\n",
|
||
" <td>73757714.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2530</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2007</td>\n",
|
||
" <td>301231207.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2531</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2007</td>\n",
|
||
" <td>74019405.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2532</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2008</td>\n",
|
||
" <td>304093966.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2533</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2008</td>\n",
|
||
" <td>74104602.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2534</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2013</td>\n",
|
||
" <td>73585872.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2535</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2013</td>\n",
|
||
" <td>316128839.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2536</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2009</td>\n",
|
||
" <td>306771529.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2537</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2009</td>\n",
|
||
" <td>74134167.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2538</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>74119556.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2539</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>309326295.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2540</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>73902222.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2541</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>311582564.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2542</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>73708179.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2543</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>313873685.0</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"<p>2544 rows × 4 columns</p>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state/region ages year population\n",
|
||
"0 AL under18 2012 1117489.0\n",
|
||
"1 AL total 2012 4817528.0\n",
|
||
"2 AL under18 2010 1130966.0\n",
|
||
"3 AL total 2010 4785570.0\n",
|
||
"4 AL under18 2011 1125763.0\n",
|
||
"5 AL total 2011 4801627.0\n",
|
||
"6 AL total 2009 4757938.0\n",
|
||
"7 AL under18 2009 1134192.0\n",
|
||
"8 AL under18 2013 1111481.0\n",
|
||
"9 AL total 2013 4833722.0\n",
|
||
"10 AL total 2007 4672840.0\n",
|
||
"11 AL under18 2007 1132296.0\n",
|
||
"12 AL total 2008 4718206.0\n",
|
||
"13 AL under18 2008 1134927.0\n",
|
||
"14 AL total 2005 4569805.0\n",
|
||
"15 AL under18 2005 1117229.0\n",
|
||
"16 AL total 2006 4628981.0\n",
|
||
"17 AL under18 2006 1126798.0\n",
|
||
"18 AL total 2004 4530729.0\n",
|
||
"19 AL under18 2004 1113662.0\n",
|
||
"20 AL total 2003 4503491.0\n",
|
||
"21 AL under18 2003 1113083.0\n",
|
||
"22 AL total 2001 4467634.0\n",
|
||
"23 AL under18 2001 1120409.0\n",
|
||
"24 AL total 2002 4480089.0\n",
|
||
"25 AL under18 2002 1116590.0\n",
|
||
"26 AL under18 1999 1121287.0\n",
|
||
"27 AL total 1999 4430141.0\n",
|
||
"28 AL total 2000 4452173.0\n",
|
||
"29 AL under18 2000 1122273.0\n",
|
||
"... ... ... ... ...\n",
|
||
"2514 USA under18 1999 71946051.0\n",
|
||
"2515 USA total 2000 282162411.0\n",
|
||
"2516 USA under18 2000 72376189.0\n",
|
||
"2517 USA total 1999 279040181.0\n",
|
||
"2518 USA total 2001 284968955.0\n",
|
||
"2519 USA under18 2001 72671175.0\n",
|
||
"2520 USA total 2002 287625193.0\n",
|
||
"2521 USA under18 2002 72936457.0\n",
|
||
"2522 USA total 2003 290107933.0\n",
|
||
"2523 USA under18 2003 73100758.0\n",
|
||
"2524 USA total 2004 292805298.0\n",
|
||
"2525 USA under18 2004 73297735.0\n",
|
||
"2526 USA total 2005 295516599.0\n",
|
||
"2527 USA under18 2005 73523669.0\n",
|
||
"2528 USA total 2006 298379912.0\n",
|
||
"2529 USA under18 2006 73757714.0\n",
|
||
"2530 USA total 2007 301231207.0\n",
|
||
"2531 USA under18 2007 74019405.0\n",
|
||
"2532 USA total 2008 304093966.0\n",
|
||
"2533 USA under18 2008 74104602.0\n",
|
||
"2534 USA under18 2013 73585872.0\n",
|
||
"2535 USA total 2013 316128839.0\n",
|
||
"2536 USA total 2009 306771529.0\n",
|
||
"2537 USA under18 2009 74134167.0\n",
|
||
"2538 USA under18 2010 74119556.0\n",
|
||
"2539 USA total 2010 309326295.0\n",
|
||
"2540 USA under18 2011 73902222.0\n",
|
||
"2541 USA total 2011 311582564.0\n",
|
||
"2542 USA under18 2012 73708179.0\n",
|
||
"2543 USA total 2012 313873685.0\n",
|
||
"\n",
|
||
"[2544 rows x 4 columns]"
|
||
]
|
||
},
|
||
"execution_count": 6,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"# 美国的人口数据\n",
|
||
"pop = pd.read_csv('./state-population.csv')\n",
|
||
"pop"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 8,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"(2544, 4)"
|
||
]
|
||
},
|
||
"execution_count": 8,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop.shape"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 7,
|
||
"metadata": {
|
||
"scrolled": false
|
||
},
|
||
"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>state/region</th>\n",
|
||
" <th>ages</th>\n",
|
||
" <th>year</th>\n",
|
||
" <th>population</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1117489.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4817528.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>1130966.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>4785570.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>1125763.0</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state/region ages year population\n",
|
||
"0 AL under18 2012 1117489.0\n",
|
||
"1 AL total 2012 4817528.0\n",
|
||
"2 AL under18 2010 1130966.0\n",
|
||
"3 AL total 2010 4785570.0\n",
|
||
"4 AL under18 2011 1125763.0"
|
||
]
|
||
},
|
||
"execution_count": 7,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 11,
|
||
"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>state</th>\n",
|
||
" <th>abbreviation</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>AL</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>Alaska</td>\n",
|
||
" <td>AK</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>Arizona</td>\n",
|
||
" <td>AZ</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>Arkansas</td>\n",
|
||
" <td>AR</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>California</td>\n",
|
||
" <td>CA</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state abbreviation\n",
|
||
"0 Alabama AL\n",
|
||
"1 Alaska AK\n",
|
||
"2 Arizona AZ\n",
|
||
"3 Arkansas AR\n",
|
||
"4 California CA"
|
||
]
|
||
},
|
||
"execution_count": 11,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"abbrevs.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 9,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"(2544, 4)"
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"output_type": "display_data"
|
||
},
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"(51, 2)"
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"output_type": "display_data"
|
||
}
|
||
],
|
||
"source": [
|
||
"display(pop.shape,abbrevs.shape)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 15,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"(2544, 6)"
|
||
]
|
||
},
|
||
"execution_count": 15,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"# 级联时,数据变少了96个,哪些数据变少\n",
|
||
"# inner内连接,outer叫做外连接\n",
|
||
"pop2 = pop.merge(abbrevs,how = 'outer',left_on='state/region',right_on='abbreviation')\n",
|
||
"pop2.shape"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 17,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"state/region False\n",
|
||
"ages False\n",
|
||
"year False\n",
|
||
"population True\n",
|
||
"state True\n",
|
||
"abbreviation True\n",
|
||
"dtype: bool"
|
||
]
|
||
},
|
||
"execution_count": 17,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"# 前三列没有空值\n",
|
||
"pop2.isnull().any()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 18,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"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>state/region</th>\n",
|
||
" <th>ages</th>\n",
|
||
" <th>year</th>\n",
|
||
" <th>population</th>\n",
|
||
" <th>state</th>\n",
|
||
" <th>abbreviation</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1117489.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>AL</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4817528.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>AL</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>1130966.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>AL</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>4785570.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>AL</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>1125763.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>AL</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state/region ages year population state abbreviation\n",
|
||
"0 AL under18 2012 1117489.0 Alabama AL\n",
|
||
"1 AL total 2012 4817528.0 Alabama AL\n",
|
||
"2 AL under18 2010 1130966.0 Alabama AL\n",
|
||
"3 AL total 2010 4785570.0 Alabama AL\n",
|
||
"4 AL under18 2011 1125763.0 Alabama AL"
|
||
]
|
||
},
|
||
"execution_count": 18,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop2.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 20,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"# 删除一列\n",
|
||
"pop2.drop(labels = 'abbreviation',axis = 1,inplace=True)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 21,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"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>state/region</th>\n",
|
||
" <th>ages</th>\n",
|
||
" <th>year</th>\n",
|
||
" <th>population</th>\n",
|
||
" <th>state</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1117489.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4817528.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>1130966.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>4785570.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>1125763.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state/region ages year population state\n",
|
||
"0 AL under18 2012 1117489.0 Alabama\n",
|
||
"1 AL total 2012 4817528.0 Alabama\n",
|
||
"2 AL under18 2010 1130966.0 Alabama\n",
|
||
"3 AL total 2010 4785570.0 Alabama\n",
|
||
"4 AL under18 2011 1125763.0 Alabama"
|
||
]
|
||
},
|
||
"execution_count": 21,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop2.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 22,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"state/region False\n",
|
||
"ages False\n",
|
||
"year False\n",
|
||
"population True\n",
|
||
"state True\n",
|
||
"dtype: bool"
|
||
]
|
||
},
|
||
"execution_count": 22,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop2.isnull().any()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 24,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"0 False\n",
|
||
"1 False\n",
|
||
"2 False\n",
|
||
"3 False\n",
|
||
"4 False\n",
|
||
"5 False\n",
|
||
"6 False\n",
|
||
"7 False\n",
|
||
"8 False\n",
|
||
"9 False\n",
|
||
"10 False\n",
|
||
"11 False\n",
|
||
"12 False\n",
|
||
"13 False\n",
|
||
"14 False\n",
|
||
"15 False\n",
|
||
"16 False\n",
|
||
"17 False\n",
|
||
"18 False\n",
|
||
"19 False\n",
|
||
"20 False\n",
|
||
"21 False\n",
|
||
"22 False\n",
|
||
"23 False\n",
|
||
"24 False\n",
|
||
"25 False\n",
|
||
"26 False\n",
|
||
"27 False\n",
|
||
"28 False\n",
|
||
"29 False\n",
|
||
" ... \n",
|
||
"2514 True\n",
|
||
"2515 True\n",
|
||
"2516 True\n",
|
||
"2517 True\n",
|
||
"2518 True\n",
|
||
"2519 True\n",
|
||
"2520 True\n",
|
||
"2521 True\n",
|
||
"2522 True\n",
|
||
"2523 True\n",
|
||
"2524 True\n",
|
||
"2525 True\n",
|
||
"2526 True\n",
|
||
"2527 True\n",
|
||
"2528 True\n",
|
||
"2529 True\n",
|
||
"2530 True\n",
|
||
"2531 True\n",
|
||
"2532 True\n",
|
||
"2533 True\n",
|
||
"2534 True\n",
|
||
"2535 True\n",
|
||
"2536 True\n",
|
||
"2537 True\n",
|
||
"2538 True\n",
|
||
"2539 True\n",
|
||
"2540 True\n",
|
||
"2541 True\n",
|
||
"2542 True\n",
|
||
"2543 True\n",
|
||
"Name: state, Length: 2544, dtype: bool"
|
||
]
|
||
},
|
||
"execution_count": 24,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"# 定位为空的数据\n",
|
||
"cond = pop2['state'].isnull()\n",
|
||
"cond"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 27,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"array(['PR', 'USA'], dtype=object)"
|
||
]
|
||
},
|
||
"execution_count": 27,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"# 只有当state为空,返回,为空时True\n",
|
||
"# 去重操作,非重复值\n",
|
||
"pop2[cond]['state/region'].unique()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 30,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"(51, 2)"
|
||
]
|
||
},
|
||
"execution_count": 30,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"abbrevs.shape"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 31,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"(52, 2)"
|
||
]
|
||
},
|
||
"execution_count": 31,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"areas.shape"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 32,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"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>state</th>\n",
|
||
" <th>area (sq. mi)</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>Alaska</td>\n",
|
||
" <td>656425</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>Arizona</td>\n",
|
||
" <td>114006</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>Arkansas</td>\n",
|
||
" <td>53182</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>California</td>\n",
|
||
" <td>163707</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>5</th>\n",
|
||
" <td>Colorado</td>\n",
|
||
" <td>104100</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>6</th>\n",
|
||
" <td>Connecticut</td>\n",
|
||
" <td>5544</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>7</th>\n",
|
||
" <td>Delaware</td>\n",
|
||
" <td>1954</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>8</th>\n",
|
||
" <td>Florida</td>\n",
|
||
" <td>65758</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>9</th>\n",
|
||
" <td>Georgia</td>\n",
|
||
" <td>59441</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>10</th>\n",
|
||
" <td>Hawaii</td>\n",
|
||
" <td>10932</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>11</th>\n",
|
||
" <td>Idaho</td>\n",
|
||
" <td>83574</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>12</th>\n",
|
||
" <td>Illinois</td>\n",
|
||
" <td>57918</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>13</th>\n",
|
||
" <td>Indiana</td>\n",
|
||
" <td>36420</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>14</th>\n",
|
||
" <td>Iowa</td>\n",
|
||
" <td>56276</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>15</th>\n",
|
||
" <td>Kansas</td>\n",
|
||
" <td>82282</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>16</th>\n",
|
||
" <td>Kentucky</td>\n",
|
||
" <td>40411</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>17</th>\n",
|
||
" <td>Louisiana</td>\n",
|
||
" <td>51843</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>18</th>\n",
|
||
" <td>Maine</td>\n",
|
||
" <td>35387</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>19</th>\n",
|
||
" <td>Maryland</td>\n",
|
||
" <td>12407</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>20</th>\n",
|
||
" <td>Massachusetts</td>\n",
|
||
" <td>10555</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>21</th>\n",
|
||
" <td>Michigan</td>\n",
|
||
" <td>96810</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>22</th>\n",
|
||
" <td>Minnesota</td>\n",
|
||
" <td>86943</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>23</th>\n",
|
||
" <td>Mississippi</td>\n",
|
||
" <td>48434</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>24</th>\n",
|
||
" <td>Missouri</td>\n",
|
||
" <td>69709</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>25</th>\n",
|
||
" <td>Montana</td>\n",
|
||
" <td>147046</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>26</th>\n",
|
||
" <td>Nebraska</td>\n",
|
||
" <td>77358</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>27</th>\n",
|
||
" <td>Nevada</td>\n",
|
||
" <td>110567</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>28</th>\n",
|
||
" <td>New Hampshire</td>\n",
|
||
" <td>9351</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>29</th>\n",
|
||
" <td>New Jersey</td>\n",
|
||
" <td>8722</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>30</th>\n",
|
||
" <td>New Mexico</td>\n",
|
||
" <td>121593</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>31</th>\n",
|
||
" <td>New York</td>\n",
|
||
" <td>54475</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>32</th>\n",
|
||
" <td>North Carolina</td>\n",
|
||
" <td>53821</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>33</th>\n",
|
||
" <td>North Dakota</td>\n",
|
||
" <td>70704</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>34</th>\n",
|
||
" <td>Ohio</td>\n",
|
||
" <td>44828</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>35</th>\n",
|
||
" <td>Oklahoma</td>\n",
|
||
" <td>69903</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>36</th>\n",
|
||
" <td>Oregon</td>\n",
|
||
" <td>98386</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>37</th>\n",
|
||
" <td>Pennsylvania</td>\n",
|
||
" <td>46058</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>38</th>\n",
|
||
" <td>Rhode Island</td>\n",
|
||
" <td>1545</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>39</th>\n",
|
||
" <td>South Carolina</td>\n",
|
||
" <td>32007</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>40</th>\n",
|
||
" <td>South Dakota</td>\n",
|
||
" <td>77121</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>41</th>\n",
|
||
" <td>Tennessee</td>\n",
|
||
" <td>42146</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>42</th>\n",
|
||
" <td>Texas</td>\n",
|
||
" <td>268601</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>43</th>\n",
|
||
" <td>Utah</td>\n",
|
||
" <td>84904</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>44</th>\n",
|
||
" <td>Vermont</td>\n",
|
||
" <td>9615</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>45</th>\n",
|
||
" <td>Virginia</td>\n",
|
||
" <td>42769</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>46</th>\n",
|
||
" <td>Washington</td>\n",
|
||
" <td>71303</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>47</th>\n",
|
||
" <td>West Virginia</td>\n",
|
||
" <td>24231</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>48</th>\n",
|
||
" <td>Wisconsin</td>\n",
|
||
" <td>65503</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>49</th>\n",
|
||
" <td>Wyoming</td>\n",
|
||
" <td>97818</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>50</th>\n",
|
||
" <td>District of Columbia</td>\n",
|
||
" <td>68</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>51</th>\n",
|
||
" <td>Puerto Rico</td>\n",
|
||
" <td>3515</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state area (sq. mi)\n",
|
||
"0 Alabama 52423\n",
|
||
"1 Alaska 656425\n",
|
||
"2 Arizona 114006\n",
|
||
"3 Arkansas 53182\n",
|
||
"4 California 163707\n",
|
||
"5 Colorado 104100\n",
|
||
"6 Connecticut 5544\n",
|
||
"7 Delaware 1954\n",
|
||
"8 Florida 65758\n",
|
||
"9 Georgia 59441\n",
|
||
"10 Hawaii 10932\n",
|
||
"11 Idaho 83574\n",
|
||
"12 Illinois 57918\n",
|
||
"13 Indiana 36420\n",
|
||
"14 Iowa 56276\n",
|
||
"15 Kansas 82282\n",
|
||
"16 Kentucky 40411\n",
|
||
"17 Louisiana 51843\n",
|
||
"18 Maine 35387\n",
|
||
"19 Maryland 12407\n",
|
||
"20 Massachusetts 10555\n",
|
||
"21 Michigan 96810\n",
|
||
"22 Minnesota 86943\n",
|
||
"23 Mississippi 48434\n",
|
||
"24 Missouri 69709\n",
|
||
"25 Montana 147046\n",
|
||
"26 Nebraska 77358\n",
|
||
"27 Nevada 110567\n",
|
||
"28 New Hampshire 9351\n",
|
||
"29 New Jersey 8722\n",
|
||
"30 New Mexico 121593\n",
|
||
"31 New York 54475\n",
|
||
"32 North Carolina 53821\n",
|
||
"33 North Dakota 70704\n",
|
||
"34 Ohio 44828\n",
|
||
"35 Oklahoma 69903\n",
|
||
"36 Oregon 98386\n",
|
||
"37 Pennsylvania 46058\n",
|
||
"38 Rhode Island 1545\n",
|
||
"39 South Carolina 32007\n",
|
||
"40 South Dakota 77121\n",
|
||
"41 Tennessee 42146\n",
|
||
"42 Texas 268601\n",
|
||
"43 Utah 84904\n",
|
||
"44 Vermont 9615\n",
|
||
"45 Virginia 42769\n",
|
||
"46 Washington 71303\n",
|
||
"47 West Virginia 24231\n",
|
||
"48 Wisconsin 65503\n",
|
||
"49 Wyoming 97818\n",
|
||
"50 District of Columbia 68\n",
|
||
"51 Puerto Rico 3515"
|
||
]
|
||
},
|
||
"execution_count": 32,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"areas"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 34,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"0 False\n",
|
||
"1 False\n",
|
||
"2 False\n",
|
||
"3 False\n",
|
||
"4 False\n",
|
||
"5 False\n",
|
||
"6 False\n",
|
||
"7 False\n",
|
||
"8 False\n",
|
||
"9 False\n",
|
||
"10 False\n",
|
||
"11 False\n",
|
||
"12 False\n",
|
||
"13 False\n",
|
||
"14 False\n",
|
||
"15 False\n",
|
||
"16 False\n",
|
||
"17 False\n",
|
||
"18 False\n",
|
||
"19 False\n",
|
||
"20 False\n",
|
||
"21 False\n",
|
||
"22 False\n",
|
||
"23 False\n",
|
||
"24 False\n",
|
||
"25 False\n",
|
||
"26 False\n",
|
||
"27 False\n",
|
||
"28 False\n",
|
||
"29 False\n",
|
||
" ... \n",
|
||
"2514 False\n",
|
||
"2515 False\n",
|
||
"2516 False\n",
|
||
"2517 False\n",
|
||
"2518 False\n",
|
||
"2519 False\n",
|
||
"2520 False\n",
|
||
"2521 False\n",
|
||
"2522 False\n",
|
||
"2523 False\n",
|
||
"2524 False\n",
|
||
"2525 False\n",
|
||
"2526 False\n",
|
||
"2527 False\n",
|
||
"2528 False\n",
|
||
"2529 False\n",
|
||
"2530 False\n",
|
||
"2531 False\n",
|
||
"2532 False\n",
|
||
"2533 False\n",
|
||
"2534 False\n",
|
||
"2535 False\n",
|
||
"2536 False\n",
|
||
"2537 False\n",
|
||
"2538 False\n",
|
||
"2539 False\n",
|
||
"2540 False\n",
|
||
"2541 False\n",
|
||
"2542 False\n",
|
||
"2543 False\n",
|
||
"Name: state/region, Length: 2544, dtype: bool"
|
||
]
|
||
},
|
||
"execution_count": 34,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"cond = pop2['state/region'] == 'PR'\n",
|
||
"cond"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 36,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stderr",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"d:\\python36\\lib\\site-packages\\ipykernel_launcher.py:1: SettingWithCopyWarning: \n",
|
||
"A value is trying to be set on a copy of a slice from a DataFrame\n",
|
||
"\n",
|
||
"See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
|
||
" \"\"\"Entry point for launching an IPython kernel.\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"pop2['state'][cond] = 'Puerto Rico'"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 38,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stderr",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"d:\\python36\\lib\\site-packages\\ipykernel_launcher.py:2: SettingWithCopyWarning: \n",
|
||
"A value is trying to be set on a copy of a slice from a DataFrame\n",
|
||
"\n",
|
||
"See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
|
||
" \n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"cond = pop2['state/region'] == 'USA'\n",
|
||
"pop2['state'][cond] = 'United State'"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 39,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"state/region False\n",
|
||
"ages False\n",
|
||
"year False\n",
|
||
"population True\n",
|
||
"state False\n",
|
||
"dtype: bool"
|
||
]
|
||
},
|
||
"execution_count": 39,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop2.isnull().any()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 42,
|
||
"metadata": {
|
||
"scrolled": false
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"(20, 5)"
|
||
]
|
||
},
|
||
"execution_count": 42,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"cond = pop2['population'].isnull()\n",
|
||
"pop2[cond].shape"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 43,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"(2544, 5)"
|
||
]
|
||
},
|
||
"execution_count": 43,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop2.shape"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 45,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"# 将难于进行补全的空数据进行删除\n",
|
||
"pop2.dropna(inplace=True)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 46,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"(2524, 5)"
|
||
]
|
||
},
|
||
"execution_count": 46,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop2.shape"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 47,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"state/region False\n",
|
||
"ages False\n",
|
||
"year False\n",
|
||
"population False\n",
|
||
"state False\n",
|
||
"dtype: bool"
|
||
]
|
||
},
|
||
"execution_count": 47,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop2.isnull().any()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 48,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"state/region True\n",
|
||
"ages True\n",
|
||
"year True\n",
|
||
"population True\n",
|
||
"state True\n",
|
||
"dtype: bool"
|
||
]
|
||
},
|
||
"execution_count": 48,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop2.notnull().all()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 50,
|
||
"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>state</th>\n",
|
||
" <th>area (sq. mi)</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>Alaska</td>\n",
|
||
" <td>656425</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>Arizona</td>\n",
|
||
" <td>114006</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>Arkansas</td>\n",
|
||
" <td>53182</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>California</td>\n",
|
||
" <td>163707</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state area (sq. mi)\n",
|
||
"0 Alabama 52423\n",
|
||
"1 Alaska 656425\n",
|
||
"2 Arizona 114006\n",
|
||
"3 Arkansas 53182\n",
|
||
"4 California 163707"
|
||
]
|
||
},
|
||
"execution_count": 50,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"areas.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 49,
|
||
"metadata": {
|
||
"scrolled": false
|
||
},
|
||
"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>state/region</th>\n",
|
||
" <th>ages</th>\n",
|
||
" <th>year</th>\n",
|
||
" <th>population</th>\n",
|
||
" <th>state</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1117489.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4817528.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>1130966.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>4785570.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>1125763.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state/region ages year population state\n",
|
||
"0 AL under18 2012 1117489.0 Alabama\n",
|
||
"1 AL total 2012 4817528.0 Alabama\n",
|
||
"2 AL under18 2010 1130966.0 Alabama\n",
|
||
"3 AL total 2010 4785570.0 Alabama\n",
|
||
"4 AL under18 2011 1125763.0 Alabama"
|
||
]
|
||
},
|
||
"execution_count": 49,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop2.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 51,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"(2524, 6)"
|
||
]
|
||
},
|
||
"execution_count": 51,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop3 = pop2.merge(areas,how = 'outer')\n",
|
||
"pop3.shape"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 52,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"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>state/region</th>\n",
|
||
" <th>ages</th>\n",
|
||
" <th>year</th>\n",
|
||
" <th>population</th>\n",
|
||
" <th>state</th>\n",
|
||
" <th>area (sq. mi)</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1117489.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4817528.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>1130966.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>4785570.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>1125763.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state/region ages year population state area (sq. mi)\n",
|
||
"0 AL under18 2012 1117489.0 Alabama 52423.0\n",
|
||
"1 AL total 2012 4817528.0 Alabama 52423.0\n",
|
||
"2 AL under18 2010 1130966.0 Alabama 52423.0\n",
|
||
"3 AL total 2010 4785570.0 Alabama 52423.0\n",
|
||
"4 AL under18 2011 1125763.0 Alabama 52423.0"
|
||
]
|
||
},
|
||
"execution_count": 52,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop3.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 53,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"state/region False\n",
|
||
"ages False\n",
|
||
"year False\n",
|
||
"population False\n",
|
||
"state False\n",
|
||
"area (sq. mi) True\n",
|
||
"dtype: bool"
|
||
]
|
||
},
|
||
"execution_count": 53,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop3.isnull().any()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 54,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"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>state/region</th>\n",
|
||
" <th>ages</th>\n",
|
||
" <th>year</th>\n",
|
||
" <th>population</th>\n",
|
||
" <th>state</th>\n",
|
||
" <th>area (sq. mi)</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>2476</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>1990</td>\n",
|
||
" <td>64218512.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2477</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>1990</td>\n",
|
||
" <td>249622814.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2478</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>1991</td>\n",
|
||
" <td>252980942.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2479</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>1991</td>\n",
|
||
" <td>65313018.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2480</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>1992</td>\n",
|
||
" <td>66509177.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2481</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>1992</td>\n",
|
||
" <td>256514231.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2482</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>1993</td>\n",
|
||
" <td>259918595.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2483</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>1993</td>\n",
|
||
" <td>67594938.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2484</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>1994</td>\n",
|
||
" <td>68640936.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2485</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>1994</td>\n",
|
||
" <td>263125826.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2486</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>1995</td>\n",
|
||
" <td>69473140.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2487</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>1996</td>\n",
|
||
" <td>70233512.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2488</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>1995</td>\n",
|
||
" <td>266278403.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2489</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>1996</td>\n",
|
||
" <td>269394291.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2490</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>1997</td>\n",
|
||
" <td>272646932.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2491</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>1997</td>\n",
|
||
" <td>70920738.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2492</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>1998</td>\n",
|
||
" <td>71431406.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2493</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>1998</td>\n",
|
||
" <td>275854116.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2494</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>1999</td>\n",
|
||
" <td>71946051.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2495</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2000</td>\n",
|
||
" <td>282162411.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2496</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2000</td>\n",
|
||
" <td>72376189.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2497</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>1999</td>\n",
|
||
" <td>279040181.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2498</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2001</td>\n",
|
||
" <td>284968955.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2499</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2001</td>\n",
|
||
" <td>72671175.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2500</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2002</td>\n",
|
||
" <td>287625193.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2501</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2002</td>\n",
|
||
" <td>72936457.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2502</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2003</td>\n",
|
||
" <td>290107933.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2503</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2003</td>\n",
|
||
" <td>73100758.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2504</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2004</td>\n",
|
||
" <td>292805298.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2505</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2004</td>\n",
|
||
" <td>73297735.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2506</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2005</td>\n",
|
||
" <td>295516599.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2507</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2005</td>\n",
|
||
" <td>73523669.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2508</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2006</td>\n",
|
||
" <td>298379912.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2509</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2006</td>\n",
|
||
" <td>73757714.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2510</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2007</td>\n",
|
||
" <td>301231207.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2511</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2007</td>\n",
|
||
" <td>74019405.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2512</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2008</td>\n",
|
||
" <td>304093966.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2513</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2008</td>\n",
|
||
" <td>74104602.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2514</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2013</td>\n",
|
||
" <td>73585872.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2515</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2013</td>\n",
|
||
" <td>316128839.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2516</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2009</td>\n",
|
||
" <td>306771529.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2517</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2009</td>\n",
|
||
" <td>74134167.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2518</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>74119556.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2519</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>309326295.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2520</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>73902222.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2521</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>311582564.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2522</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>73708179.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2523</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>313873685.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state/region ages year population state area (sq. mi)\n",
|
||
"2476 USA under18 1990 64218512.0 United State NaN\n",
|
||
"2477 USA total 1990 249622814.0 United State NaN\n",
|
||
"2478 USA total 1991 252980942.0 United State NaN\n",
|
||
"2479 USA under18 1991 65313018.0 United State NaN\n",
|
||
"2480 USA under18 1992 66509177.0 United State NaN\n",
|
||
"2481 USA total 1992 256514231.0 United State NaN\n",
|
||
"2482 USA total 1993 259918595.0 United State NaN\n",
|
||
"2483 USA under18 1993 67594938.0 United State NaN\n",
|
||
"2484 USA under18 1994 68640936.0 United State NaN\n",
|
||
"2485 USA total 1994 263125826.0 United State NaN\n",
|
||
"2486 USA under18 1995 69473140.0 United State NaN\n",
|
||
"2487 USA under18 1996 70233512.0 United State NaN\n",
|
||
"2488 USA total 1995 266278403.0 United State NaN\n",
|
||
"2489 USA total 1996 269394291.0 United State NaN\n",
|
||
"2490 USA total 1997 272646932.0 United State NaN\n",
|
||
"2491 USA under18 1997 70920738.0 United State NaN\n",
|
||
"2492 USA under18 1998 71431406.0 United State NaN\n",
|
||
"2493 USA total 1998 275854116.0 United State NaN\n",
|
||
"2494 USA under18 1999 71946051.0 United State NaN\n",
|
||
"2495 USA total 2000 282162411.0 United State NaN\n",
|
||
"2496 USA under18 2000 72376189.0 United State NaN\n",
|
||
"2497 USA total 1999 279040181.0 United State NaN\n",
|
||
"2498 USA total 2001 284968955.0 United State NaN\n",
|
||
"2499 USA under18 2001 72671175.0 United State NaN\n",
|
||
"2500 USA total 2002 287625193.0 United State NaN\n",
|
||
"2501 USA under18 2002 72936457.0 United State NaN\n",
|
||
"2502 USA total 2003 290107933.0 United State NaN\n",
|
||
"2503 USA under18 2003 73100758.0 United State NaN\n",
|
||
"2504 USA total 2004 292805298.0 United State NaN\n",
|
||
"2505 USA under18 2004 73297735.0 United State NaN\n",
|
||
"2506 USA total 2005 295516599.0 United State NaN\n",
|
||
"2507 USA under18 2005 73523669.0 United State NaN\n",
|
||
"2508 USA total 2006 298379912.0 United State NaN\n",
|
||
"2509 USA under18 2006 73757714.0 United State NaN\n",
|
||
"2510 USA total 2007 301231207.0 United State NaN\n",
|
||
"2511 USA under18 2007 74019405.0 United State NaN\n",
|
||
"2512 USA total 2008 304093966.0 United State NaN\n",
|
||
"2513 USA under18 2008 74104602.0 United State NaN\n",
|
||
"2514 USA under18 2013 73585872.0 United State NaN\n",
|
||
"2515 USA total 2013 316128839.0 United State NaN\n",
|
||
"2516 USA total 2009 306771529.0 United State NaN\n",
|
||
"2517 USA under18 2009 74134167.0 United State NaN\n",
|
||
"2518 USA under18 2010 74119556.0 United State NaN\n",
|
||
"2519 USA total 2010 309326295.0 United State NaN\n",
|
||
"2520 USA under18 2011 73902222.0 United State NaN\n",
|
||
"2521 USA total 2011 311582564.0 United State NaN\n",
|
||
"2522 USA under18 2012 73708179.0 United State NaN\n",
|
||
"2523 USA total 2012 313873685.0 United State NaN"
|
||
]
|
||
},
|
||
"execution_count": 54,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"cond = pop3['area (sq. mi)'].isnull()\n",
|
||
"pop3[cond]"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 58,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"3790399"
|
||
]
|
||
},
|
||
"execution_count": 58,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"a = areas['area (sq. mi)'].sum()\n",
|
||
"a"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 60,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stderr",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"d:\\python36\\lib\\site-packages\\ipykernel_launcher.py:3: SettingWithCopyWarning: \n",
|
||
"A value is trying to be set on a copy of a slice from a DataFrame\n",
|
||
"\n",
|
||
"See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
|
||
" This is separate from the ipykernel package so we can avoid doing imports until\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"cond = pop3['state'] == \"United State\"\n",
|
||
"\n",
|
||
"pop3['area (sq. mi)'][cond] = a"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 61,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"state/region True\n",
|
||
"ages True\n",
|
||
"year True\n",
|
||
"population True\n",
|
||
"state True\n",
|
||
"area (sq. mi) True\n",
|
||
"dtype: bool"
|
||
]
|
||
},
|
||
"execution_count": 61,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop3.notnull().all()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 62,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"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>state/region</th>\n",
|
||
" <th>ages</th>\n",
|
||
" <th>year</th>\n",
|
||
" <th>population</th>\n",
|
||
" <th>state</th>\n",
|
||
" <th>area (sq. mi)</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1117489.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4817528.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>1130966.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>4785570.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>1125763.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state/region ages year population state area (sq. mi)\n",
|
||
"0 AL under18 2012 1117489.0 Alabama 52423.0\n",
|
||
"1 AL total 2012 4817528.0 Alabama 52423.0\n",
|
||
"2 AL under18 2010 1130966.0 Alabama 52423.0\n",
|
||
"3 AL total 2010 4785570.0 Alabama 52423.0\n",
|
||
"4 AL under18 2011 1125763.0 Alabama 52423.0"
|
||
]
|
||
},
|
||
"execution_count": 62,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop3.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 66,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"0 21.3\n",
|
||
"1 91.9\n",
|
||
"2 21.6\n",
|
||
"3 91.3\n",
|
||
"4 21.5\n",
|
||
"5 91.6\n",
|
||
"6 90.8\n",
|
||
"7 21.6\n",
|
||
"8 21.2\n",
|
||
"9 92.2\n",
|
||
"10 89.1\n",
|
||
"11 21.6\n",
|
||
"12 90.0\n",
|
||
"13 21.6\n",
|
||
"14 87.2\n",
|
||
"15 21.3\n",
|
||
"16 88.3\n",
|
||
"17 21.5\n",
|
||
"18 86.4\n",
|
||
"19 21.2\n",
|
||
"20 85.9\n",
|
||
"21 21.2\n",
|
||
"22 85.2\n",
|
||
"23 21.4\n",
|
||
"24 85.5\n",
|
||
"25 21.3\n",
|
||
"26 21.4\n",
|
||
"27 84.5\n",
|
||
"28 84.9\n",
|
||
"29 21.4\n",
|
||
" ... \n",
|
||
"2494 19.0\n",
|
||
"2495 74.4\n",
|
||
"2496 19.1\n",
|
||
"2497 73.6\n",
|
||
"2498 75.2\n",
|
||
"2499 19.2\n",
|
||
"2500 75.9\n",
|
||
"2501 19.2\n",
|
||
"2502 76.5\n",
|
||
"2503 19.3\n",
|
||
"2504 77.2\n",
|
||
"2505 19.3\n",
|
||
"2506 78.0\n",
|
||
"2507 19.4\n",
|
||
"2508 78.7\n",
|
||
"2509 19.5\n",
|
||
"2510 79.5\n",
|
||
"2511 19.5\n",
|
||
"2512 80.2\n",
|
||
"2513 19.6\n",
|
||
"2514 19.4\n",
|
||
"2515 83.4\n",
|
||
"2516 80.9\n",
|
||
"2517 19.6\n",
|
||
"2518 19.6\n",
|
||
"2519 81.6\n",
|
||
"2520 19.5\n",
|
||
"2521 82.2\n",
|
||
"2522 19.4\n",
|
||
"2523 82.8\n",
|
||
"Length: 2524, dtype: float64"
|
||
]
|
||
},
|
||
"execution_count": 66,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop_density = (pop3['population']/pop3['area (sq. mi)']).round(1)\n",
|
||
"pop_density"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 67,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"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>0</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>21.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>91.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>21.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>91.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>21.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>5</th>\n",
|
||
" <td>91.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>6</th>\n",
|
||
" <td>90.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>7</th>\n",
|
||
" <td>21.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>8</th>\n",
|
||
" <td>21.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>9</th>\n",
|
||
" <td>92.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>10</th>\n",
|
||
" <td>89.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>11</th>\n",
|
||
" <td>21.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>12</th>\n",
|
||
" <td>90.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>13</th>\n",
|
||
" <td>21.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>14</th>\n",
|
||
" <td>87.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>15</th>\n",
|
||
" <td>21.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>16</th>\n",
|
||
" <td>88.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>17</th>\n",
|
||
" <td>21.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>18</th>\n",
|
||
" <td>86.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>19</th>\n",
|
||
" <td>21.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>20</th>\n",
|
||
" <td>85.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>21</th>\n",
|
||
" <td>21.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>22</th>\n",
|
||
" <td>85.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>23</th>\n",
|
||
" <td>21.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>24</th>\n",
|
||
" <td>85.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>25</th>\n",
|
||
" <td>21.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>26</th>\n",
|
||
" <td>21.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>27</th>\n",
|
||
" <td>84.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>28</th>\n",
|
||
" <td>84.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>29</th>\n",
|
||
" <td>21.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>...</th>\n",
|
||
" <td>...</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2494</th>\n",
|
||
" <td>19.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2495</th>\n",
|
||
" <td>74.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2496</th>\n",
|
||
" <td>19.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2497</th>\n",
|
||
" <td>73.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2498</th>\n",
|
||
" <td>75.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2499</th>\n",
|
||
" <td>19.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2500</th>\n",
|
||
" <td>75.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2501</th>\n",
|
||
" <td>19.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2502</th>\n",
|
||
" <td>76.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2503</th>\n",
|
||
" <td>19.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2504</th>\n",
|
||
" <td>77.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2505</th>\n",
|
||
" <td>19.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2506</th>\n",
|
||
" <td>78.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2507</th>\n",
|
||
" <td>19.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2508</th>\n",
|
||
" <td>78.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2509</th>\n",
|
||
" <td>19.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2510</th>\n",
|
||
" <td>79.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2511</th>\n",
|
||
" <td>19.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2512</th>\n",
|
||
" <td>80.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2513</th>\n",
|
||
" <td>19.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2514</th>\n",
|
||
" <td>19.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2515</th>\n",
|
||
" <td>83.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2516</th>\n",
|
||
" <td>80.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2517</th>\n",
|
||
" <td>19.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2518</th>\n",
|
||
" <td>19.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2519</th>\n",
|
||
" <td>81.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2520</th>\n",
|
||
" <td>19.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2521</th>\n",
|
||
" <td>82.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2522</th>\n",
|
||
" <td>19.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2523</th>\n",
|
||
" <td>82.8</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"<p>2524 rows × 1 columns</p>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" 0\n",
|
||
"0 21.3\n",
|
||
"1 91.9\n",
|
||
"2 21.6\n",
|
||
"3 91.3\n",
|
||
"4 21.5\n",
|
||
"5 91.6\n",
|
||
"6 90.8\n",
|
||
"7 21.6\n",
|
||
"8 21.2\n",
|
||
"9 92.2\n",
|
||
"10 89.1\n",
|
||
"11 21.6\n",
|
||
"12 90.0\n",
|
||
"13 21.6\n",
|
||
"14 87.2\n",
|
||
"15 21.3\n",
|
||
"16 88.3\n",
|
||
"17 21.5\n",
|
||
"18 86.4\n",
|
||
"19 21.2\n",
|
||
"20 85.9\n",
|
||
"21 21.2\n",
|
||
"22 85.2\n",
|
||
"23 21.4\n",
|
||
"24 85.5\n",
|
||
"25 21.3\n",
|
||
"26 21.4\n",
|
||
"27 84.5\n",
|
||
"28 84.9\n",
|
||
"29 21.4\n",
|
||
"... ...\n",
|
||
"2494 19.0\n",
|
||
"2495 74.4\n",
|
||
"2496 19.1\n",
|
||
"2497 73.6\n",
|
||
"2498 75.2\n",
|
||
"2499 19.2\n",
|
||
"2500 75.9\n",
|
||
"2501 19.2\n",
|
||
"2502 76.5\n",
|
||
"2503 19.3\n",
|
||
"2504 77.2\n",
|
||
"2505 19.3\n",
|
||
"2506 78.0\n",
|
||
"2507 19.4\n",
|
||
"2508 78.7\n",
|
||
"2509 19.5\n",
|
||
"2510 79.5\n",
|
||
"2511 19.5\n",
|
||
"2512 80.2\n",
|
||
"2513 19.6\n",
|
||
"2514 19.4\n",
|
||
"2515 83.4\n",
|
||
"2516 80.9\n",
|
||
"2517 19.6\n",
|
||
"2518 19.6\n",
|
||
"2519 81.6\n",
|
||
"2520 19.5\n",
|
||
"2521 82.2\n",
|
||
"2522 19.4\n",
|
||
"2523 82.8\n",
|
||
"\n",
|
||
"[2524 rows x 1 columns]"
|
||
]
|
||
},
|
||
"execution_count": 67,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop_density = DataFrame(pop_density)\n",
|
||
"pop_density"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 68,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"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>pop_density</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>21.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>91.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>21.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>91.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>21.5</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" pop_density\n",
|
||
"0 21.3\n",
|
||
"1 91.9\n",
|
||
"2 21.6\n",
|
||
"3 91.3\n",
|
||
"4 21.5"
|
||
]
|
||
},
|
||
"execution_count": 68,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop_density.columns = ['pop_density']\n",
|
||
"pop_density.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 69,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"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>state/region</th>\n",
|
||
" <th>ages</th>\n",
|
||
" <th>year</th>\n",
|
||
" <th>population</th>\n",
|
||
" <th>state</th>\n",
|
||
" <th>area (sq. mi)</th>\n",
|
||
" <th>pop_density</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1117489.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" <td>21.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4817528.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" <td>91.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>1130966.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" <td>21.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2010</td>\n",
|
||
" <td>4785570.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" <td>91.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>under18</td>\n",
|
||
" <td>2011</td>\n",
|
||
" <td>1125763.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" <td>21.5</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state/region ages year population state area (sq. mi) pop_density\n",
|
||
"0 AL under18 2012 1117489.0 Alabama 52423.0 21.3\n",
|
||
"1 AL total 2012 4817528.0 Alabama 52423.0 91.9\n",
|
||
"2 AL under18 2010 1130966.0 Alabama 52423.0 21.6\n",
|
||
"3 AL total 2010 4785570.0 Alabama 52423.0 91.3\n",
|
||
"4 AL under18 2011 1125763.0 Alabama 52423.0 21.5"
|
||
]
|
||
},
|
||
"execution_count": 69,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop4 = pop3.merge(pop_density,left_index=True,right_index=True)\n",
|
||
"pop4.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 70,
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"array([2012, 2010, 2011, 2009, 2013, 2007, 2008, 2005, 2006, 2004, 2003,\n",
|
||
" 2001, 2002, 1999, 2000, 1998, 1997, 1996, 1995, 1994, 1993, 1992,\n",
|
||
" 1991, 1990], dtype=int64)"
|
||
]
|
||
},
|
||
"execution_count": 70,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop4['year'].unique()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 71,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"array(['under18', 'total'], dtype=object)"
|
||
]
|
||
},
|
||
"execution_count": 71,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop4['ages'].unique()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 73,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"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>state/region</th>\n",
|
||
" <th>ages</th>\n",
|
||
" <th>year</th>\n",
|
||
" <th>population</th>\n",
|
||
" <th>state</th>\n",
|
||
" <th>area (sq. mi)</th>\n",
|
||
" <th>pop_density</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>AL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4817528.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" <td>91.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>95</th>\n",
|
||
" <td>AK</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>730307.0</td>\n",
|
||
" <td>Alaska</td>\n",
|
||
" <td>656425.0</td>\n",
|
||
" <td>1.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>97</th>\n",
|
||
" <td>AZ</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6551149.0</td>\n",
|
||
" <td>Arizona</td>\n",
|
||
" <td>114006.0</td>\n",
|
||
" <td>57.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>191</th>\n",
|
||
" <td>AR</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2949828.0</td>\n",
|
||
" <td>Arkansas</td>\n",
|
||
" <td>53182.0</td>\n",
|
||
" <td>55.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>193</th>\n",
|
||
" <td>CA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>37999878.0</td>\n",
|
||
" <td>California</td>\n",
|
||
" <td>163707.0</td>\n",
|
||
" <td>232.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>287</th>\n",
|
||
" <td>CO</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>5189458.0</td>\n",
|
||
" <td>Colorado</td>\n",
|
||
" <td>104100.0</td>\n",
|
||
" <td>49.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>289</th>\n",
|
||
" <td>CT</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3591765.0</td>\n",
|
||
" <td>Connecticut</td>\n",
|
||
" <td>5544.0</td>\n",
|
||
" <td>647.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>383</th>\n",
|
||
" <td>DE</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>917053.0</td>\n",
|
||
" <td>Delaware</td>\n",
|
||
" <td>1954.0</td>\n",
|
||
" <td>469.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>385</th>\n",
|
||
" <td>DC</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>633427.0</td>\n",
|
||
" <td>District of Columbia</td>\n",
|
||
" <td>68.0</td>\n",
|
||
" <td>9315.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>479</th>\n",
|
||
" <td>FL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>19320749.0</td>\n",
|
||
" <td>Florida</td>\n",
|
||
" <td>65758.0</td>\n",
|
||
" <td>293.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>480</th>\n",
|
||
" <td>GA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>9915646.0</td>\n",
|
||
" <td>Georgia</td>\n",
|
||
" <td>59441.0</td>\n",
|
||
" <td>166.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>575</th>\n",
|
||
" <td>HI</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1390090.0</td>\n",
|
||
" <td>Hawaii</td>\n",
|
||
" <td>10932.0</td>\n",
|
||
" <td>127.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>576</th>\n",
|
||
" <td>ID</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1595590.0</td>\n",
|
||
" <td>Idaho</td>\n",
|
||
" <td>83574.0</td>\n",
|
||
" <td>19.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>671</th>\n",
|
||
" <td>IL</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>12868192.0</td>\n",
|
||
" <td>Illinois</td>\n",
|
||
" <td>57918.0</td>\n",
|
||
" <td>222.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>672</th>\n",
|
||
" <td>IN</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6537782.0</td>\n",
|
||
" <td>Indiana</td>\n",
|
||
" <td>36420.0</td>\n",
|
||
" <td>179.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>767</th>\n",
|
||
" <td>IA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3075039.0</td>\n",
|
||
" <td>Iowa</td>\n",
|
||
" <td>56276.0</td>\n",
|
||
" <td>54.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>768</th>\n",
|
||
" <td>KS</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2885398.0</td>\n",
|
||
" <td>Kansas</td>\n",
|
||
" <td>82282.0</td>\n",
|
||
" <td>35.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>863</th>\n",
|
||
" <td>KY</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4379730.0</td>\n",
|
||
" <td>Kentucky</td>\n",
|
||
" <td>40411.0</td>\n",
|
||
" <td>108.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>864</th>\n",
|
||
" <td>LA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4602134.0</td>\n",
|
||
" <td>Louisiana</td>\n",
|
||
" <td>51843.0</td>\n",
|
||
" <td>88.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>959</th>\n",
|
||
" <td>ME</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1328501.0</td>\n",
|
||
" <td>Maine</td>\n",
|
||
" <td>35387.0</td>\n",
|
||
" <td>37.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>960</th>\n",
|
||
" <td>MD</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>5884868.0</td>\n",
|
||
" <td>Maryland</td>\n",
|
||
" <td>12407.0</td>\n",
|
||
" <td>474.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1055</th>\n",
|
||
" <td>MA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6645303.0</td>\n",
|
||
" <td>Massachusetts</td>\n",
|
||
" <td>10555.0</td>\n",
|
||
" <td>629.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1056</th>\n",
|
||
" <td>MI</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>9882519.0</td>\n",
|
||
" <td>Michigan</td>\n",
|
||
" <td>96810.0</td>\n",
|
||
" <td>102.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1151</th>\n",
|
||
" <td>MN</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>5379646.0</td>\n",
|
||
" <td>Minnesota</td>\n",
|
||
" <td>86943.0</td>\n",
|
||
" <td>61.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1152</th>\n",
|
||
" <td>MS</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2986450.0</td>\n",
|
||
" <td>Mississippi</td>\n",
|
||
" <td>48434.0</td>\n",
|
||
" <td>61.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1247</th>\n",
|
||
" <td>MO</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6024522.0</td>\n",
|
||
" <td>Missouri</td>\n",
|
||
" <td>69709.0</td>\n",
|
||
" <td>86.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1248</th>\n",
|
||
" <td>MT</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1005494.0</td>\n",
|
||
" <td>Montana</td>\n",
|
||
" <td>147046.0</td>\n",
|
||
" <td>6.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1343</th>\n",
|
||
" <td>NE</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1855350.0</td>\n",
|
||
" <td>Nebraska</td>\n",
|
||
" <td>77358.0</td>\n",
|
||
" <td>24.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1344</th>\n",
|
||
" <td>NV</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2754354.0</td>\n",
|
||
" <td>Nevada</td>\n",
|
||
" <td>110567.0</td>\n",
|
||
" <td>24.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1439</th>\n",
|
||
" <td>NH</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1321617.0</td>\n",
|
||
" <td>New Hampshire</td>\n",
|
||
" <td>9351.0</td>\n",
|
||
" <td>141.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1440</th>\n",
|
||
" <td>NJ</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>8867749.0</td>\n",
|
||
" <td>New Jersey</td>\n",
|
||
" <td>8722.0</td>\n",
|
||
" <td>1016.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1535</th>\n",
|
||
" <td>NM</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2083540.0</td>\n",
|
||
" <td>New Mexico</td>\n",
|
||
" <td>121593.0</td>\n",
|
||
" <td>17.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1536</th>\n",
|
||
" <td>NY</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>19576125.0</td>\n",
|
||
" <td>New York</td>\n",
|
||
" <td>54475.0</td>\n",
|
||
" <td>359.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1631</th>\n",
|
||
" <td>NC</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>9748364.0</td>\n",
|
||
" <td>North Carolina</td>\n",
|
||
" <td>53821.0</td>\n",
|
||
" <td>181.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1632</th>\n",
|
||
" <td>ND</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>701345.0</td>\n",
|
||
" <td>North Dakota</td>\n",
|
||
" <td>70704.0</td>\n",
|
||
" <td>9.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1727</th>\n",
|
||
" <td>OH</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>11553031.0</td>\n",
|
||
" <td>Ohio</td>\n",
|
||
" <td>44828.0</td>\n",
|
||
" <td>257.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1728</th>\n",
|
||
" <td>OK</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3815780.0</td>\n",
|
||
" <td>Oklahoma</td>\n",
|
||
" <td>69903.0</td>\n",
|
||
" <td>54.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1823</th>\n",
|
||
" <td>OR</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3899801.0</td>\n",
|
||
" <td>Oregon</td>\n",
|
||
" <td>98386.0</td>\n",
|
||
" <td>39.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1824</th>\n",
|
||
" <td>PA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>12764475.0</td>\n",
|
||
" <td>Pennsylvania</td>\n",
|
||
" <td>46058.0</td>\n",
|
||
" <td>277.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1919</th>\n",
|
||
" <td>RI</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1050304.0</td>\n",
|
||
" <td>Rhode Island</td>\n",
|
||
" <td>1545.0</td>\n",
|
||
" <td>679.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1920</th>\n",
|
||
" <td>SC</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4723417.0</td>\n",
|
||
" <td>South Carolina</td>\n",
|
||
" <td>32007.0</td>\n",
|
||
" <td>147.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2015</th>\n",
|
||
" <td>SD</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>834047.0</td>\n",
|
||
" <td>South Dakota</td>\n",
|
||
" <td>77121.0</td>\n",
|
||
" <td>10.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2016</th>\n",
|
||
" <td>TN</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6454914.0</td>\n",
|
||
" <td>Tennessee</td>\n",
|
||
" <td>42146.0</td>\n",
|
||
" <td>153.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2111</th>\n",
|
||
" <td>TX</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>26060796.0</td>\n",
|
||
" <td>Texas</td>\n",
|
||
" <td>268601.0</td>\n",
|
||
" <td>97.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2112</th>\n",
|
||
" <td>UT</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2854871.0</td>\n",
|
||
" <td>Utah</td>\n",
|
||
" <td>84904.0</td>\n",
|
||
" <td>33.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2207</th>\n",
|
||
" <td>VT</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>625953.0</td>\n",
|
||
" <td>Vermont</td>\n",
|
||
" <td>9615.0</td>\n",
|
||
" <td>65.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2208</th>\n",
|
||
" <td>VA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>8186628.0</td>\n",
|
||
" <td>Virginia</td>\n",
|
||
" <td>42769.0</td>\n",
|
||
" <td>191.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2303</th>\n",
|
||
" <td>WA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6895318.0</td>\n",
|
||
" <td>Washington</td>\n",
|
||
" <td>71303.0</td>\n",
|
||
" <td>96.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2304</th>\n",
|
||
" <td>WV</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1856680.0</td>\n",
|
||
" <td>West Virginia</td>\n",
|
||
" <td>24231.0</td>\n",
|
||
" <td>76.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2399</th>\n",
|
||
" <td>WI</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>5724554.0</td>\n",
|
||
" <td>Wisconsin</td>\n",
|
||
" <td>65503.0</td>\n",
|
||
" <td>87.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2400</th>\n",
|
||
" <td>WY</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>576626.0</td>\n",
|
||
" <td>Wyoming</td>\n",
|
||
" <td>97818.0</td>\n",
|
||
" <td>5.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2475</th>\n",
|
||
" <td>PR</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3651545.0</td>\n",
|
||
" <td>Puerto Rico</td>\n",
|
||
" <td>3515.0</td>\n",
|
||
" <td>1038.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2523</th>\n",
|
||
" <td>USA</td>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>313873685.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>3790399.0</td>\n",
|
||
" <td>82.8</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" state/region ages year population state area (sq. mi) pop_density\n",
|
||
"1 AL total 2012 4817528.0 Alabama 52423.0 91.9\n",
|
||
"95 AK total 2012 730307.0 Alaska 656425.0 1.1\n",
|
||
"97 AZ total 2012 6551149.0 Arizona 114006.0 57.5\n",
|
||
"191 AR total 2012 2949828.0 Arkansas 53182.0 55.5\n",
|
||
"193 CA total 2012 37999878.0 California 163707.0 232.1\n",
|
||
"287 CO total 2012 5189458.0 Colorado 104100.0 49.9\n",
|
||
"289 CT total 2012 3591765.0 Connecticut 5544.0 647.9\n",
|
||
"383 DE total 2012 917053.0 Delaware 1954.0 469.3\n",
|
||
"385 DC total 2012 633427.0 District of Columbia 68.0 9315.1\n",
|
||
"479 FL total 2012 19320749.0 Florida 65758.0 293.8\n",
|
||
"480 GA total 2012 9915646.0 Georgia 59441.0 166.8\n",
|
||
"575 HI total 2012 1390090.0 Hawaii 10932.0 127.2\n",
|
||
"576 ID total 2012 1595590.0 Idaho 83574.0 19.1\n",
|
||
"671 IL total 2012 12868192.0 Illinois 57918.0 222.2\n",
|
||
"672 IN total 2012 6537782.0 Indiana 36420.0 179.5\n",
|
||
"767 IA total 2012 3075039.0 Iowa 56276.0 54.6\n",
|
||
"768 KS total 2012 2885398.0 Kansas 82282.0 35.1\n",
|
||
"863 KY total 2012 4379730.0 Kentucky 40411.0 108.4\n",
|
||
"864 LA total 2012 4602134.0 Louisiana 51843.0 88.8\n",
|
||
"959 ME total 2012 1328501.0 Maine 35387.0 37.5\n",
|
||
"960 MD total 2012 5884868.0 Maryland 12407.0 474.3\n",
|
||
"1055 MA total 2012 6645303.0 Massachusetts 10555.0 629.6\n",
|
||
"1056 MI total 2012 9882519.0 Michigan 96810.0 102.1\n",
|
||
"1151 MN total 2012 5379646.0 Minnesota 86943.0 61.9\n",
|
||
"1152 MS total 2012 2986450.0 Mississippi 48434.0 61.7\n",
|
||
"1247 MO total 2012 6024522.0 Missouri 69709.0 86.4\n",
|
||
"1248 MT total 2012 1005494.0 Montana 147046.0 6.8\n",
|
||
"1343 NE total 2012 1855350.0 Nebraska 77358.0 24.0\n",
|
||
"1344 NV total 2012 2754354.0 Nevada 110567.0 24.9\n",
|
||
"1439 NH total 2012 1321617.0 New Hampshire 9351.0 141.3\n",
|
||
"1440 NJ total 2012 8867749.0 New Jersey 8722.0 1016.7\n",
|
||
"1535 NM total 2012 2083540.0 New Mexico 121593.0 17.1\n",
|
||
"1536 NY total 2012 19576125.0 New York 54475.0 359.4\n",
|
||
"1631 NC total 2012 9748364.0 North Carolina 53821.0 181.1\n",
|
||
"1632 ND total 2012 701345.0 North Dakota 70704.0 9.9\n",
|
||
"1727 OH total 2012 11553031.0 Ohio 44828.0 257.7\n",
|
||
"1728 OK total 2012 3815780.0 Oklahoma 69903.0 54.6\n",
|
||
"1823 OR total 2012 3899801.0 Oregon 98386.0 39.6\n",
|
||
"1824 PA total 2012 12764475.0 Pennsylvania 46058.0 277.1\n",
|
||
"1919 RI total 2012 1050304.0 Rhode Island 1545.0 679.8\n",
|
||
"1920 SC total 2012 4723417.0 South Carolina 32007.0 147.6\n",
|
||
"2015 SD total 2012 834047.0 South Dakota 77121.0 10.8\n",
|
||
"2016 TN total 2012 6454914.0 Tennessee 42146.0 153.2\n",
|
||
"2111 TX total 2012 26060796.0 Texas 268601.0 97.0\n",
|
||
"2112 UT total 2012 2854871.0 Utah 84904.0 33.6\n",
|
||
"2207 VT total 2012 625953.0 Vermont 9615.0 65.1\n",
|
||
"2208 VA total 2012 8186628.0 Virginia 42769.0 191.4\n",
|
||
"2303 WA total 2012 6895318.0 Washington 71303.0 96.7\n",
|
||
"2304 WV total 2012 1856680.0 West Virginia 24231.0 76.6\n",
|
||
"2399 WI total 2012 5724554.0 Wisconsin 65503.0 87.4\n",
|
||
"2400 WY total 2012 576626.0 Wyoming 97818.0 5.9\n",
|
||
"2475 PR total 2012 3651545.0 Puerto Rico 3515.0 1038.8\n",
|
||
"2523 USA total 2012 313873685.0 United State 3790399.0 82.8"
|
||
]
|
||
},
|
||
"execution_count": 73,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"# 查找2012年美国各州的全民人口数据\n",
|
||
"\n",
|
||
"# pandas非常强大的,可以像查询数据库一样进行数据查询\n",
|
||
"\n",
|
||
"pop5 = pop4.query(\"year == 2012 and ages == 'total'\")\n",
|
||
"pop5"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 78,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"pop5.set_index(keys = 'state/region',inplace=True)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 80,
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"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>ages</th>\n",
|
||
" <th>year</th>\n",
|
||
" <th>population</th>\n",
|
||
" <th>state</th>\n",
|
||
" <th>area (sq. mi)</th>\n",
|
||
" <th>pop_density</th>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>state/region</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>AK</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>730307.0</td>\n",
|
||
" <td>Alaska</td>\n",
|
||
" <td>656425.0</td>\n",
|
||
" <td>1.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>WY</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>576626.0</td>\n",
|
||
" <td>Wyoming</td>\n",
|
||
" <td>97818.0</td>\n",
|
||
" <td>5.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MT</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1005494.0</td>\n",
|
||
" <td>Montana</td>\n",
|
||
" <td>147046.0</td>\n",
|
||
" <td>6.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>ND</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>701345.0</td>\n",
|
||
" <td>North Dakota</td>\n",
|
||
" <td>70704.0</td>\n",
|
||
" <td>9.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>SD</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>834047.0</td>\n",
|
||
" <td>South Dakota</td>\n",
|
||
" <td>77121.0</td>\n",
|
||
" <td>10.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NM</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2083540.0</td>\n",
|
||
" <td>New Mexico</td>\n",
|
||
" <td>121593.0</td>\n",
|
||
" <td>17.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>ID</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1595590.0</td>\n",
|
||
" <td>Idaho</td>\n",
|
||
" <td>83574.0</td>\n",
|
||
" <td>19.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NE</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1855350.0</td>\n",
|
||
" <td>Nebraska</td>\n",
|
||
" <td>77358.0</td>\n",
|
||
" <td>24.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NV</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2754354.0</td>\n",
|
||
" <td>Nevada</td>\n",
|
||
" <td>110567.0</td>\n",
|
||
" <td>24.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>UT</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2854871.0</td>\n",
|
||
" <td>Utah</td>\n",
|
||
" <td>84904.0</td>\n",
|
||
" <td>33.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>KS</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2885398.0</td>\n",
|
||
" <td>Kansas</td>\n",
|
||
" <td>82282.0</td>\n",
|
||
" <td>35.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>ME</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1328501.0</td>\n",
|
||
" <td>Maine</td>\n",
|
||
" <td>35387.0</td>\n",
|
||
" <td>37.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>OR</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3899801.0</td>\n",
|
||
" <td>Oregon</td>\n",
|
||
" <td>98386.0</td>\n",
|
||
" <td>39.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>CO</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>5189458.0</td>\n",
|
||
" <td>Colorado</td>\n",
|
||
" <td>104100.0</td>\n",
|
||
" <td>49.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>IA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3075039.0</td>\n",
|
||
" <td>Iowa</td>\n",
|
||
" <td>56276.0</td>\n",
|
||
" <td>54.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>OK</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3815780.0</td>\n",
|
||
" <td>Oklahoma</td>\n",
|
||
" <td>69903.0</td>\n",
|
||
" <td>54.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>AR</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2949828.0</td>\n",
|
||
" <td>Arkansas</td>\n",
|
||
" <td>53182.0</td>\n",
|
||
" <td>55.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>AZ</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6551149.0</td>\n",
|
||
" <td>Arizona</td>\n",
|
||
" <td>114006.0</td>\n",
|
||
" <td>57.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MS</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2986450.0</td>\n",
|
||
" <td>Mississippi</td>\n",
|
||
" <td>48434.0</td>\n",
|
||
" <td>61.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MN</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>5379646.0</td>\n",
|
||
" <td>Minnesota</td>\n",
|
||
" <td>86943.0</td>\n",
|
||
" <td>61.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>VT</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>625953.0</td>\n",
|
||
" <td>Vermont</td>\n",
|
||
" <td>9615.0</td>\n",
|
||
" <td>65.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>WV</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1856680.0</td>\n",
|
||
" <td>West Virginia</td>\n",
|
||
" <td>24231.0</td>\n",
|
||
" <td>76.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>USA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>313873685.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>3790399.0</td>\n",
|
||
" <td>82.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MO</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6024522.0</td>\n",
|
||
" <td>Missouri</td>\n",
|
||
" <td>69709.0</td>\n",
|
||
" <td>86.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>WI</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>5724554.0</td>\n",
|
||
" <td>Wisconsin</td>\n",
|
||
" <td>65503.0</td>\n",
|
||
" <td>87.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>LA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4602134.0</td>\n",
|
||
" <td>Louisiana</td>\n",
|
||
" <td>51843.0</td>\n",
|
||
" <td>88.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>AL</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4817528.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" <td>91.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>WA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6895318.0</td>\n",
|
||
" <td>Washington</td>\n",
|
||
" <td>71303.0</td>\n",
|
||
" <td>96.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>TX</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>26060796.0</td>\n",
|
||
" <td>Texas</td>\n",
|
||
" <td>268601.0</td>\n",
|
||
" <td>97.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MI</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>9882519.0</td>\n",
|
||
" <td>Michigan</td>\n",
|
||
" <td>96810.0</td>\n",
|
||
" <td>102.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>KY</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4379730.0</td>\n",
|
||
" <td>Kentucky</td>\n",
|
||
" <td>40411.0</td>\n",
|
||
" <td>108.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>HI</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1390090.0</td>\n",
|
||
" <td>Hawaii</td>\n",
|
||
" <td>10932.0</td>\n",
|
||
" <td>127.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NH</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1321617.0</td>\n",
|
||
" <td>New Hampshire</td>\n",
|
||
" <td>9351.0</td>\n",
|
||
" <td>141.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>SC</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4723417.0</td>\n",
|
||
" <td>South Carolina</td>\n",
|
||
" <td>32007.0</td>\n",
|
||
" <td>147.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>TN</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6454914.0</td>\n",
|
||
" <td>Tennessee</td>\n",
|
||
" <td>42146.0</td>\n",
|
||
" <td>153.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>GA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>9915646.0</td>\n",
|
||
" <td>Georgia</td>\n",
|
||
" <td>59441.0</td>\n",
|
||
" <td>166.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>IN</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6537782.0</td>\n",
|
||
" <td>Indiana</td>\n",
|
||
" <td>36420.0</td>\n",
|
||
" <td>179.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NC</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>9748364.0</td>\n",
|
||
" <td>North Carolina</td>\n",
|
||
" <td>53821.0</td>\n",
|
||
" <td>181.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>VA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>8186628.0</td>\n",
|
||
" <td>Virginia</td>\n",
|
||
" <td>42769.0</td>\n",
|
||
" <td>191.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>IL</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>12868192.0</td>\n",
|
||
" <td>Illinois</td>\n",
|
||
" <td>57918.0</td>\n",
|
||
" <td>222.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>CA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>37999878.0</td>\n",
|
||
" <td>California</td>\n",
|
||
" <td>163707.0</td>\n",
|
||
" <td>232.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>OH</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>11553031.0</td>\n",
|
||
" <td>Ohio</td>\n",
|
||
" <td>44828.0</td>\n",
|
||
" <td>257.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>PA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>12764475.0</td>\n",
|
||
" <td>Pennsylvania</td>\n",
|
||
" <td>46058.0</td>\n",
|
||
" <td>277.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>FL</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>19320749.0</td>\n",
|
||
" <td>Florida</td>\n",
|
||
" <td>65758.0</td>\n",
|
||
" <td>293.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NY</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>19576125.0</td>\n",
|
||
" <td>New York</td>\n",
|
||
" <td>54475.0</td>\n",
|
||
" <td>359.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>DE</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>917053.0</td>\n",
|
||
" <td>Delaware</td>\n",
|
||
" <td>1954.0</td>\n",
|
||
" <td>469.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MD</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>5884868.0</td>\n",
|
||
" <td>Maryland</td>\n",
|
||
" <td>12407.0</td>\n",
|
||
" <td>474.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6645303.0</td>\n",
|
||
" <td>Massachusetts</td>\n",
|
||
" <td>10555.0</td>\n",
|
||
" <td>629.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>CT</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3591765.0</td>\n",
|
||
" <td>Connecticut</td>\n",
|
||
" <td>5544.0</td>\n",
|
||
" <td>647.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>RI</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1050304.0</td>\n",
|
||
" <td>Rhode Island</td>\n",
|
||
" <td>1545.0</td>\n",
|
||
" <td>679.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NJ</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>8867749.0</td>\n",
|
||
" <td>New Jersey</td>\n",
|
||
" <td>8722.0</td>\n",
|
||
" <td>1016.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>PR</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3651545.0</td>\n",
|
||
" <td>Puerto Rico</td>\n",
|
||
" <td>3515.0</td>\n",
|
||
" <td>1038.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>DC</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>633427.0</td>\n",
|
||
" <td>District of Columbia</td>\n",
|
||
" <td>68.0</td>\n",
|
||
" <td>9315.1</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" ages year population state area (sq. mi) pop_density\n",
|
||
"state/region \n",
|
||
"AK total 2012 730307.0 Alaska 656425.0 1.1\n",
|
||
"WY total 2012 576626.0 Wyoming 97818.0 5.9\n",
|
||
"MT total 2012 1005494.0 Montana 147046.0 6.8\n",
|
||
"ND total 2012 701345.0 North Dakota 70704.0 9.9\n",
|
||
"SD total 2012 834047.0 South Dakota 77121.0 10.8\n",
|
||
"NM total 2012 2083540.0 New Mexico 121593.0 17.1\n",
|
||
"ID total 2012 1595590.0 Idaho 83574.0 19.1\n",
|
||
"NE total 2012 1855350.0 Nebraska 77358.0 24.0\n",
|
||
"NV total 2012 2754354.0 Nevada 110567.0 24.9\n",
|
||
"UT total 2012 2854871.0 Utah 84904.0 33.6\n",
|
||
"KS total 2012 2885398.0 Kansas 82282.0 35.1\n",
|
||
"ME total 2012 1328501.0 Maine 35387.0 37.5\n",
|
||
"OR total 2012 3899801.0 Oregon 98386.0 39.6\n",
|
||
"CO total 2012 5189458.0 Colorado 104100.0 49.9\n",
|
||
"IA total 2012 3075039.0 Iowa 56276.0 54.6\n",
|
||
"OK total 2012 3815780.0 Oklahoma 69903.0 54.6\n",
|
||
"AR total 2012 2949828.0 Arkansas 53182.0 55.5\n",
|
||
"AZ total 2012 6551149.0 Arizona 114006.0 57.5\n",
|
||
"MS total 2012 2986450.0 Mississippi 48434.0 61.7\n",
|
||
"MN total 2012 5379646.0 Minnesota 86943.0 61.9\n",
|
||
"VT total 2012 625953.0 Vermont 9615.0 65.1\n",
|
||
"WV total 2012 1856680.0 West Virginia 24231.0 76.6\n",
|
||
"USA total 2012 313873685.0 United State 3790399.0 82.8\n",
|
||
"MO total 2012 6024522.0 Missouri 69709.0 86.4\n",
|
||
"WI total 2012 5724554.0 Wisconsin 65503.0 87.4\n",
|
||
"LA total 2012 4602134.0 Louisiana 51843.0 88.8\n",
|
||
"AL total 2012 4817528.0 Alabama 52423.0 91.9\n",
|
||
"WA total 2012 6895318.0 Washington 71303.0 96.7\n",
|
||
"TX total 2012 26060796.0 Texas 268601.0 97.0\n",
|
||
"MI total 2012 9882519.0 Michigan 96810.0 102.1\n",
|
||
"KY total 2012 4379730.0 Kentucky 40411.0 108.4\n",
|
||
"HI total 2012 1390090.0 Hawaii 10932.0 127.2\n",
|
||
"NH total 2012 1321617.0 New Hampshire 9351.0 141.3\n",
|
||
"SC total 2012 4723417.0 South Carolina 32007.0 147.6\n",
|
||
"TN total 2012 6454914.0 Tennessee 42146.0 153.2\n",
|
||
"GA total 2012 9915646.0 Georgia 59441.0 166.8\n",
|
||
"IN total 2012 6537782.0 Indiana 36420.0 179.5\n",
|
||
"NC total 2012 9748364.0 North Carolina 53821.0 181.1\n",
|
||
"VA total 2012 8186628.0 Virginia 42769.0 191.4\n",
|
||
"IL total 2012 12868192.0 Illinois 57918.0 222.2\n",
|
||
"CA total 2012 37999878.0 California 163707.0 232.1\n",
|
||
"OH total 2012 11553031.0 Ohio 44828.0 257.7\n",
|
||
"PA total 2012 12764475.0 Pennsylvania 46058.0 277.1\n",
|
||
"FL total 2012 19320749.0 Florida 65758.0 293.8\n",
|
||
"NY total 2012 19576125.0 New York 54475.0 359.4\n",
|
||
"DE total 2012 917053.0 Delaware 1954.0 469.3\n",
|
||
"MD total 2012 5884868.0 Maryland 12407.0 474.3\n",
|
||
"MA total 2012 6645303.0 Massachusetts 10555.0 629.6\n",
|
||
"CT total 2012 3591765.0 Connecticut 5544.0 647.9\n",
|
||
"RI total 2012 1050304.0 Rhode Island 1545.0 679.8\n",
|
||
"NJ total 2012 8867749.0 New Jersey 8722.0 1016.7\n",
|
||
"PR total 2012 3651545.0 Puerto Rico 3515.0 1038.8\n",
|
||
"DC total 2012 633427.0 District of Columbia 68.0 9315.1"
|
||
]
|
||
},
|
||
"execution_count": 80,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop5.sort_values(by = 'pop_density')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 81,
|
||
"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>ages</th>\n",
|
||
" <th>year</th>\n",
|
||
" <th>population</th>\n",
|
||
" <th>state</th>\n",
|
||
" <th>area (sq. mi)</th>\n",
|
||
" <th>pop_density</th>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>state/region</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>DC</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>633427.0</td>\n",
|
||
" <td>District of Columbia</td>\n",
|
||
" <td>68.0</td>\n",
|
||
" <td>9315.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>PR</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3651545.0</td>\n",
|
||
" <td>Puerto Rico</td>\n",
|
||
" <td>3515.0</td>\n",
|
||
" <td>1038.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NJ</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>8867749.0</td>\n",
|
||
" <td>New Jersey</td>\n",
|
||
" <td>8722.0</td>\n",
|
||
" <td>1016.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>RI</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1050304.0</td>\n",
|
||
" <td>Rhode Island</td>\n",
|
||
" <td>1545.0</td>\n",
|
||
" <td>679.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>CT</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3591765.0</td>\n",
|
||
" <td>Connecticut</td>\n",
|
||
" <td>5544.0</td>\n",
|
||
" <td>647.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6645303.0</td>\n",
|
||
" <td>Massachusetts</td>\n",
|
||
" <td>10555.0</td>\n",
|
||
" <td>629.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MD</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>5884868.0</td>\n",
|
||
" <td>Maryland</td>\n",
|
||
" <td>12407.0</td>\n",
|
||
" <td>474.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>DE</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>917053.0</td>\n",
|
||
" <td>Delaware</td>\n",
|
||
" <td>1954.0</td>\n",
|
||
" <td>469.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NY</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>19576125.0</td>\n",
|
||
" <td>New York</td>\n",
|
||
" <td>54475.0</td>\n",
|
||
" <td>359.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>FL</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>19320749.0</td>\n",
|
||
" <td>Florida</td>\n",
|
||
" <td>65758.0</td>\n",
|
||
" <td>293.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>PA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>12764475.0</td>\n",
|
||
" <td>Pennsylvania</td>\n",
|
||
" <td>46058.0</td>\n",
|
||
" <td>277.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>OH</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>11553031.0</td>\n",
|
||
" <td>Ohio</td>\n",
|
||
" <td>44828.0</td>\n",
|
||
" <td>257.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>CA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>37999878.0</td>\n",
|
||
" <td>California</td>\n",
|
||
" <td>163707.0</td>\n",
|
||
" <td>232.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>IL</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>12868192.0</td>\n",
|
||
" <td>Illinois</td>\n",
|
||
" <td>57918.0</td>\n",
|
||
" <td>222.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>VA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>8186628.0</td>\n",
|
||
" <td>Virginia</td>\n",
|
||
" <td>42769.0</td>\n",
|
||
" <td>191.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NC</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>9748364.0</td>\n",
|
||
" <td>North Carolina</td>\n",
|
||
" <td>53821.0</td>\n",
|
||
" <td>181.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>IN</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6537782.0</td>\n",
|
||
" <td>Indiana</td>\n",
|
||
" <td>36420.0</td>\n",
|
||
" <td>179.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>GA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>9915646.0</td>\n",
|
||
" <td>Georgia</td>\n",
|
||
" <td>59441.0</td>\n",
|
||
" <td>166.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>TN</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6454914.0</td>\n",
|
||
" <td>Tennessee</td>\n",
|
||
" <td>42146.0</td>\n",
|
||
" <td>153.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>SC</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4723417.0</td>\n",
|
||
" <td>South Carolina</td>\n",
|
||
" <td>32007.0</td>\n",
|
||
" <td>147.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NH</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1321617.0</td>\n",
|
||
" <td>New Hampshire</td>\n",
|
||
" <td>9351.0</td>\n",
|
||
" <td>141.3</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>HI</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1390090.0</td>\n",
|
||
" <td>Hawaii</td>\n",
|
||
" <td>10932.0</td>\n",
|
||
" <td>127.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>KY</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4379730.0</td>\n",
|
||
" <td>Kentucky</td>\n",
|
||
" <td>40411.0</td>\n",
|
||
" <td>108.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MI</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>9882519.0</td>\n",
|
||
" <td>Michigan</td>\n",
|
||
" <td>96810.0</td>\n",
|
||
" <td>102.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>TX</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>26060796.0</td>\n",
|
||
" <td>Texas</td>\n",
|
||
" <td>268601.0</td>\n",
|
||
" <td>97.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>WA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6895318.0</td>\n",
|
||
" <td>Washington</td>\n",
|
||
" <td>71303.0</td>\n",
|
||
" <td>96.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>AL</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4817528.0</td>\n",
|
||
" <td>Alabama</td>\n",
|
||
" <td>52423.0</td>\n",
|
||
" <td>91.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>LA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>4602134.0</td>\n",
|
||
" <td>Louisiana</td>\n",
|
||
" <td>51843.0</td>\n",
|
||
" <td>88.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>WI</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>5724554.0</td>\n",
|
||
" <td>Wisconsin</td>\n",
|
||
" <td>65503.0</td>\n",
|
||
" <td>87.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MO</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6024522.0</td>\n",
|
||
" <td>Missouri</td>\n",
|
||
" <td>69709.0</td>\n",
|
||
" <td>86.4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>USA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>313873685.0</td>\n",
|
||
" <td>United State</td>\n",
|
||
" <td>3790399.0</td>\n",
|
||
" <td>82.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>WV</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1856680.0</td>\n",
|
||
" <td>West Virginia</td>\n",
|
||
" <td>24231.0</td>\n",
|
||
" <td>76.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>VT</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>625953.0</td>\n",
|
||
" <td>Vermont</td>\n",
|
||
" <td>9615.0</td>\n",
|
||
" <td>65.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MN</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>5379646.0</td>\n",
|
||
" <td>Minnesota</td>\n",
|
||
" <td>86943.0</td>\n",
|
||
" <td>61.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MS</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2986450.0</td>\n",
|
||
" <td>Mississippi</td>\n",
|
||
" <td>48434.0</td>\n",
|
||
" <td>61.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>AZ</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>6551149.0</td>\n",
|
||
" <td>Arizona</td>\n",
|
||
" <td>114006.0</td>\n",
|
||
" <td>57.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>AR</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2949828.0</td>\n",
|
||
" <td>Arkansas</td>\n",
|
||
" <td>53182.0</td>\n",
|
||
" <td>55.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>OK</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3815780.0</td>\n",
|
||
" <td>Oklahoma</td>\n",
|
||
" <td>69903.0</td>\n",
|
||
" <td>54.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>IA</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3075039.0</td>\n",
|
||
" <td>Iowa</td>\n",
|
||
" <td>56276.0</td>\n",
|
||
" <td>54.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>CO</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>5189458.0</td>\n",
|
||
" <td>Colorado</td>\n",
|
||
" <td>104100.0</td>\n",
|
||
" <td>49.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>OR</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>3899801.0</td>\n",
|
||
" <td>Oregon</td>\n",
|
||
" <td>98386.0</td>\n",
|
||
" <td>39.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>ME</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1328501.0</td>\n",
|
||
" <td>Maine</td>\n",
|
||
" <td>35387.0</td>\n",
|
||
" <td>37.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>KS</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2885398.0</td>\n",
|
||
" <td>Kansas</td>\n",
|
||
" <td>82282.0</td>\n",
|
||
" <td>35.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>UT</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2854871.0</td>\n",
|
||
" <td>Utah</td>\n",
|
||
" <td>84904.0</td>\n",
|
||
" <td>33.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NV</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2754354.0</td>\n",
|
||
" <td>Nevada</td>\n",
|
||
" <td>110567.0</td>\n",
|
||
" <td>24.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NE</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1855350.0</td>\n",
|
||
" <td>Nebraska</td>\n",
|
||
" <td>77358.0</td>\n",
|
||
" <td>24.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>ID</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1595590.0</td>\n",
|
||
" <td>Idaho</td>\n",
|
||
" <td>83574.0</td>\n",
|
||
" <td>19.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>NM</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>2083540.0</td>\n",
|
||
" <td>New Mexico</td>\n",
|
||
" <td>121593.0</td>\n",
|
||
" <td>17.1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>SD</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>834047.0</td>\n",
|
||
" <td>South Dakota</td>\n",
|
||
" <td>77121.0</td>\n",
|
||
" <td>10.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>ND</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>701345.0</td>\n",
|
||
" <td>North Dakota</td>\n",
|
||
" <td>70704.0</td>\n",
|
||
" <td>9.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>MT</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>1005494.0</td>\n",
|
||
" <td>Montana</td>\n",
|
||
" <td>147046.0</td>\n",
|
||
" <td>6.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>WY</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>576626.0</td>\n",
|
||
" <td>Wyoming</td>\n",
|
||
" <td>97818.0</td>\n",
|
||
" <td>5.9</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>AK</th>\n",
|
||
" <td>total</td>\n",
|
||
" <td>2012</td>\n",
|
||
" <td>730307.0</td>\n",
|
||
" <td>Alaska</td>\n",
|
||
" <td>656425.0</td>\n",
|
||
" <td>1.1</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" ages year population state area (sq. mi) pop_density\n",
|
||
"state/region \n",
|
||
"DC total 2012 633427.0 District of Columbia 68.0 9315.1\n",
|
||
"PR total 2012 3651545.0 Puerto Rico 3515.0 1038.8\n",
|
||
"NJ total 2012 8867749.0 New Jersey 8722.0 1016.7\n",
|
||
"RI total 2012 1050304.0 Rhode Island 1545.0 679.8\n",
|
||
"CT total 2012 3591765.0 Connecticut 5544.0 647.9\n",
|
||
"MA total 2012 6645303.0 Massachusetts 10555.0 629.6\n",
|
||
"MD total 2012 5884868.0 Maryland 12407.0 474.3\n",
|
||
"DE total 2012 917053.0 Delaware 1954.0 469.3\n",
|
||
"NY total 2012 19576125.0 New York 54475.0 359.4\n",
|
||
"FL total 2012 19320749.0 Florida 65758.0 293.8\n",
|
||
"PA total 2012 12764475.0 Pennsylvania 46058.0 277.1\n",
|
||
"OH total 2012 11553031.0 Ohio 44828.0 257.7\n",
|
||
"CA total 2012 37999878.0 California 163707.0 232.1\n",
|
||
"IL total 2012 12868192.0 Illinois 57918.0 222.2\n",
|
||
"VA total 2012 8186628.0 Virginia 42769.0 191.4\n",
|
||
"NC total 2012 9748364.0 North Carolina 53821.0 181.1\n",
|
||
"IN total 2012 6537782.0 Indiana 36420.0 179.5\n",
|
||
"GA total 2012 9915646.0 Georgia 59441.0 166.8\n",
|
||
"TN total 2012 6454914.0 Tennessee 42146.0 153.2\n",
|
||
"SC total 2012 4723417.0 South Carolina 32007.0 147.6\n",
|
||
"NH total 2012 1321617.0 New Hampshire 9351.0 141.3\n",
|
||
"HI total 2012 1390090.0 Hawaii 10932.0 127.2\n",
|
||
"KY total 2012 4379730.0 Kentucky 40411.0 108.4\n",
|
||
"MI total 2012 9882519.0 Michigan 96810.0 102.1\n",
|
||
"TX total 2012 26060796.0 Texas 268601.0 97.0\n",
|
||
"WA total 2012 6895318.0 Washington 71303.0 96.7\n",
|
||
"AL total 2012 4817528.0 Alabama 52423.0 91.9\n",
|
||
"LA total 2012 4602134.0 Louisiana 51843.0 88.8\n",
|
||
"WI total 2012 5724554.0 Wisconsin 65503.0 87.4\n",
|
||
"MO total 2012 6024522.0 Missouri 69709.0 86.4\n",
|
||
"USA total 2012 313873685.0 United State 3790399.0 82.8\n",
|
||
"WV total 2012 1856680.0 West Virginia 24231.0 76.6\n",
|
||
"VT total 2012 625953.0 Vermont 9615.0 65.1\n",
|
||
"MN total 2012 5379646.0 Minnesota 86943.0 61.9\n",
|
||
"MS total 2012 2986450.0 Mississippi 48434.0 61.7\n",
|
||
"AZ total 2012 6551149.0 Arizona 114006.0 57.5\n",
|
||
"AR total 2012 2949828.0 Arkansas 53182.0 55.5\n",
|
||
"OK total 2012 3815780.0 Oklahoma 69903.0 54.6\n",
|
||
"IA total 2012 3075039.0 Iowa 56276.0 54.6\n",
|
||
"CO total 2012 5189458.0 Colorado 104100.0 49.9\n",
|
||
"OR total 2012 3899801.0 Oregon 98386.0 39.6\n",
|
||
"ME total 2012 1328501.0 Maine 35387.0 37.5\n",
|
||
"KS total 2012 2885398.0 Kansas 82282.0 35.1\n",
|
||
"UT total 2012 2854871.0 Utah 84904.0 33.6\n",
|
||
"NV total 2012 2754354.0 Nevada 110567.0 24.9\n",
|
||
"NE total 2012 1855350.0 Nebraska 77358.0 24.0\n",
|
||
"ID total 2012 1595590.0 Idaho 83574.0 19.1\n",
|
||
"NM total 2012 2083540.0 New Mexico 121593.0 17.1\n",
|
||
"SD total 2012 834047.0 South Dakota 77121.0 10.8\n",
|
||
"ND total 2012 701345.0 North Dakota 70704.0 9.9\n",
|
||
"MT total 2012 1005494.0 Montana 147046.0 6.8\n",
|
||
"WY total 2012 576626.0 Wyoming 97818.0 5.9\n",
|
||
"AK total 2012 730307.0 Alaska 656425.0 1.1"
|
||
]
|
||
},
|
||
"execution_count": 81,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"pop5.sort_values(by='pop_density',ascending=False)"
|
||
]
|
||
}
|
||
],
|
||
"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.6.5"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 2
|
||
}
|