Example 2: Downloading Data for All U.S. Counties

Using the Detail Tables

For this example, let's suppose we have looked up the variables we need by referring to the Table Shells. We begin by downloading the data and checking the data we have received:


In [1]:
import pandas as pd
import censusdata
pd.set_option('display.expand_frame_repr', False)
pd.set_option('display.precision', 2)

county65plus = censusdata.download('acs5', 2015, censusdata.censusgeo([('county', '*')]),
                                   ['B01001_001E', 'B01001_020E', 'B01001_021E', 'B01001_022E', 'B01001_023E',
                                    'B01001_024E', 'B01001_025E', 'B01001_044E', 'B01001_045E', 'B01001_046E',
                                    'B01001_047E', 'B01001_048E', 'B01001_049E'])
county65plus.describe()


Out[1]:
B01001_001E B01001_020E B01001_021E B01001_022E B01001_023E B01001_024E B01001_025E B01001_044E B01001_045E B01001_046E B01001_047E B01001_048E B01001_049E
count 3.22e+03 3220.00 3220.00 3220.00 3220.00 3220.00 3220.00 3220.00 3220.00 3220.00 3220.00 3220.00 3220.00
mean 9.94e+04 961.47 1201.25 1532.44 1075.61 748.45 629.46 1064.89 1350.16 1802.07 1358.99 1079.33 1236.80
std 3.19e+05 2669.50 3306.09 4193.15 2994.94 2184.18 1945.32 3085.53 3860.28 5149.07 3920.19 3183.31 3741.48
min 8.50e+01 0.00 0.00 2.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
25% 1.12e+04 134.00 173.00 234.00 165.00 106.00 80.00 136.00 178.00 252.00 196.00 143.00 157.75
50% 2.60e+04 308.00 391.50 513.00 353.00 231.00 180.50 322.00 413.00 560.00 429.00 318.00 350.50
75% 6.64e+04 750.75 949.25 1242.75 850.00 550.25 430.00 790.75 1040.75 1362.75 1012.00 789.00 847.00
max 1.00e+07 79196.00 96638.00 122804.00 88018.00 65118.00 59251.00 91381.00 114778.00 152378.00 116736.00 93446.00 110015.00

Then we keep the variables of interest, rename, and print descriptives:


In [2]:
county65plus['percent_65plus'] = (county65plus.B01001_020E + county65plus.B01001_021E + county65plus.B01001_022E
                                  + county65plus.B01001_023E + county65plus.B01001_024E + county65plus.B01001_025E
                                  + county65plus.B01001_044E + county65plus.B01001_045E + county65plus.B01001_046E
                                  + county65plus.B01001_047E + county65plus.B01001_048E
                                  + county65plus.B01001_049E) / county65plus.B01001_001E * 100
county65plus = county65plus[['B01001_001E', 'percent_65plus']]
county65plus = county65plus.rename(columns={'B01001_001E': 'population_size'})
county65plus.describe()


Out[2]:
population_size percent_65plus
count 3.22e+03 3220.00
mean 9.94e+04 17.10
std 3.19e+05 4.39
min 8.50e+01 3.30
25% 1.12e+04 14.32
50% 2.60e+04 16.78
75% 6.64e+04 19.45
max 1.00e+07 50.89

Finally, we show the 30 U.S. counties with the highest percentage aged 65+:


In [3]:
county65plus.sort_values('percent_65plus', ascending=False, inplace=True)
county65plus.head(30)


Out[3]:
population_size percent_65plus
Sumter County, Florida: Summary level: 050, state:12> county:119 108501 50.89
Charlotte County, Florida: Summary level: 050, state:12> county:015 165783 36.86
Mineral County, Colorado: Summary level: 050, state:08> county:079 733 36.56
Hooker County, Nebraska: Summary level: 050, state:31> county:091 681 35.83
La Paz County, Arizona: Summary level: 050, state:04> county:012 20335 35.17
Citrus County, Florida: Summary level: 050, state:12> county:017 139654 34.43
Wheeler County, Oregon: Summary level: 050, state:41> county:069 1348 34.35
Highland County, Virginia: Summary level: 050, state:51> county:091 2244 34.00
Real County, Texas: Summary level: 050, state:48> county:385 3356 33.97
Sierra County, New Mexico: Summary level: 050, state:35> county:051 11615 33.95
Alcona County, Michigan: Summary level: 050, state:26> county:001 10550 33.93
Lancaster County, Virginia: Summary level: 050, state:51> county:103 11129 33.91
Llano County, Texas: Summary level: 050, state:48> county:299 19323 33.63
Highlands County, Florida: Summary level: 050, state:12> county:055 98328 33.35
Sarasota County, Florida: Summary level: 050, state:12> county:115 392038 33.20
McIntosh County, North Dakota: Summary level: 050, state:38> county:051 2759 33.09
Northumberland County, Virginia: Summary level: 050, state:51> county:133 12304 33.07
Catron County, New Mexico: Summary level: 050, state:35> county:003 3583 32.71
Towns County, Georgia: Summary level: 050, state:13> county:281 10800 31.82
Hickory County, Missouri: Summary level: 050, state:29> county:085 9335 31.49
Ontonagon County, Michigan: Summary level: 050, state:26> county:131 6298 30.61
Curry County, Oregon: Summary level: 050, state:41> county:015 22338 30.48
Union County, Georgia: Summary level: 050, state:13> county:291 21725 30.43
Hinsdale County, Colorado: Summary level: 050, state:08> county:053 874 30.09
Jefferson County, Washington: Summary level: 050, state:53> county:031 30083 30.06
McPherson County, South Dakota: Summary level: 050, state:46> county:089 2263 29.74
McMullen County, Texas: Summary level: 050, state:48> county:311 778 29.69
Keweenaw County, Michigan: Summary level: 050, state:26> county:083 2198 29.66
Baxter County, Arkansas: Summary level: 050, state:05> county:005 41040 29.57
Indian River County, Florida: Summary level: 050, state:12> county:061 142866 29.51

Using the Data Profile Tables

There is more than one way to approach this problem. Let's see how to use the data profile tables for the same purpose. First, we identify the appropriate table:


In [4]:
censusdata.search('acs5', 2015, 'label', '65', tabletype='profile')[-25:]


Out[4]:
[('DP03_0135PM',
  'SELECTED ECONOMIC CHARACTERISTICS',
  'PERCENTAGE OF FAMILIES AND PEOPLE WHOSE INCOME IN THE PAST 12 MONTHS IS BELOW THE POVERTY LEVEL!!65 years and over'),
 ('DP03_0136E',
  'SELECTED ECONOMIC CHARACTERISTICS',
  'PERCENTAGE OF FAMILIES AND PEOPLE WHOSE INCOME IN THE PAST 12 MONTHS IS BELOW THE POVERTY LEVEL!!65 years and over!!People in families'),
 ('DP03_0136M',
  'SELECTED ECONOMIC CHARACTERISTICS',
  'PERCENTAGE OF FAMILIES AND PEOPLE WHOSE INCOME IN THE PAST 12 MONTHS IS BELOW THE POVERTY LEVEL!!65 years and over!!People in families'),
 ('DP03_0137E',
  'SELECTED ECONOMIC CHARACTERISTICS',
  'PERCENTAGE OF FAMILIES AND PEOPLE WHOSE INCOME IN THE PAST 12 MONTHS IS BELOW THE POVERTY LEVEL!!65 years and over!!Unrelated individuals 15 years and over'),
 ('DP03_0137M',
  'SELECTED ECONOMIC CHARACTERISTICS',
  'PERCENTAGE OF FAMILIES AND PEOPLE WHOSE INCOME IN THE PAST 12 MONTHS IS BELOW THE POVERTY LEVEL!!65 years and over!!Unrelated individuals 15 years and over'),
 ('DP05_0014E',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 to 74 years'),
 ('DP05_0014M',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 to 74 years'),
 ('DP05_0014PE',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 to 74 years'),
 ('DP05_0014PM',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 to 74 years'),
 ('DP05_0021E',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over'),
 ('DP05_0021M',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over'),
 ('DP05_0021PE',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over'),
 ('DP05_0021PM',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over'),
 ('DP05_0025E',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over'),
 ('DP05_0025M',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over'),
 ('DP05_0025PE',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over'),
 ('DP05_0025PM',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over'),
 ('DP05_0026E',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over!!Male'),
 ('DP05_0026M',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over!!Male'),
 ('DP05_0026PE',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over!!Male'),
 ('DP05_0026PM',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over!!Male'),
 ('DP05_0027E',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over!!Female'),
 ('DP05_0027M',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over!!Female'),
 ('DP05_0027PE',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over!!Female'),
 ('DP05_0027PM',
  'ACS DEMOGRAPHIC AND HOUSING ESTIMATES',
  'SEX AND AGE!!Total population!!65 years and over!!Female')]

In [5]:
censusdata.printtable(censusdata.censustable('acs5', 2015, 'DP05'))


Variable     | Table                          | Label                                                    | Type 
-------------------------------------------------------------------------------------------------------------------
DP05_0001E   | ACS DEMOGRAPHIC AND HOUSING ES | !! SEX AND AGE Total population                          | int  
DP05_0001PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! SEX AND AGE Total population                          | int  
DP05_0002E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population Male                  | int  
DP05_0002PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population Male                  | int  
DP05_0003E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population Female                | int  
DP05_0003PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population Female                | int  
DP05_0004E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population Under 5 years         | int  
DP05_0004PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population Under 5 years         | int  
DP05_0005E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 5 to 9 years          | int  
DP05_0005PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 5 to 9 years          | int  
DP05_0006E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 10 to 14 years        | int  
DP05_0006PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 10 to 14 years        | int  
DP05_0007E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 15 to 19 years        | int  
DP05_0007PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 15 to 19 years        | int  
DP05_0008E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 20 to 24 years        | int  
DP05_0008PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 20 to 24 years        | int  
DP05_0009E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 25 to 34 years        | int  
DP05_0009PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 25 to 34 years        | int  
DP05_0010E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 35 to 44 years        | int  
DP05_0010PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 35 to 44 years        | int  
DP05_0011E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 45 to 54 years        | int  
DP05_0011PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 45 to 54 years        | int  
DP05_0012E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 55 to 59 years        | int  
DP05_0012PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 55 to 59 years        | int  
DP05_0013E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 60 to 64 years        | int  
DP05_0013PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 60 to 64 years        | int  
DP05_0014E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 65 to 74 years        | int  
DP05_0014PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 65 to 74 years        | int  
DP05_0015E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 75 to 84 years        | int  
DP05_0015PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 75 to 84 years        | int  
DP05_0016E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 85 years and over     | int  
DP05_0016PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 85 years and over     | int  
DP05_0017E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population Median age (years)    | int  
DP05_0017PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population Median age (years)    | int  
DP05_0018E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 18 years and over     | int  
DP05_0018PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 18 years and over     | int  
DP05_0019E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 21 years and over     | int  
DP05_0019PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 21 years and over     | int  
DP05_0020E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 62 years and over     | int  
DP05_0020PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 62 years and over     | int  
DP05_0021E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 65 years and over     | int  
DP05_0021PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 65 years and over     | int  
DP05_0022E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 18 years and over     | int  
DP05_0022PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 18 years and over     | int  
DP05_0023E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! SEX AND AGE Total population 18 years and over  | int  
DP05_0023PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! SEX AND AGE Total population 18 years and over  | int  
DP05_0024E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! SEX AND AGE Total population 18 years and over  | int  
DP05_0024PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! SEX AND AGE Total population 18 years and over  | int  
DP05_0025E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 65 years and over     | int  
DP05_0025PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! SEX AND AGE Total population 65 years and over     | int  
DP05_0026E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! SEX AND AGE Total population 65 years and over  | int  
DP05_0026PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! SEX AND AGE Total population 65 years and over  | int  
DP05_0027E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! SEX AND AGE Total population 65 years and over  | int  
DP05_0027PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! SEX AND AGE Total population 65 years and over  | int  
DP05_0028E   | ACS DEMOGRAPHIC AND HOUSING ES | !! RACE Total population                                 | int  
DP05_0028PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! RACE Total population                                 | int  
DP05_0029E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE Total population One race                     | int  
DP05_0029PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE Total population One race                     | int  
DP05_0030E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE Total population Two or more races            | int  
DP05_0030PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE Total population Two or more races            | int  
DP05_0031E   | ACS DEMOGRAPHIC AND HOUSING ES | !! RACE One race                                         | int  
DP05_0031PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! RACE One race                                         | int  
DP05_0032E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE One race White                                | int  
DP05_0032PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE One race White                                | int  
DP05_0033E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE One race Black or African American            | int  
DP05_0033PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE One race Black or African American            | int  
DP05_0034E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE One race American Indian and Alaska Native    | int  
DP05_0034PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE One race American Indian and Alaska Native    | int  
DP05_0035E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race American Indian and Alaska Native | int  
DP05_0035PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race American Indian and Alaska Native | int  
DP05_0036E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race American Indian and Alaska Native | int  
DP05_0036PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race American Indian and Alaska Native | int  
DP05_0037E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race American Indian and Alaska Native | int  
DP05_0037PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race American Indian and Alaska Native | int  
DP05_0038E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race American Indian and Alaska Native | int  
DP05_0038PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race American Indian and Alaska Native | int  
DP05_0039E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE One race Asian                                | int  
DP05_0039PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE One race Asian                                | int  
DP05_0040E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Asian Indian                | int  
DP05_0040PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Asian Indian                | int  
DP05_0041E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Chinese                     | int  
DP05_0041PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Chinese                     | int  
DP05_0042E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Filipino                    | int  
DP05_0042PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Filipino                    | int  
DP05_0043E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Japanese                    | int  
DP05_0043PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Japanese                    | int  
DP05_0044E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Korean                      | int  
DP05_0044PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Korean                      | int  
DP05_0045E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Vietnamese                  | int  
DP05_0045PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Vietnamese                  | int  
DP05_0046E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Other Asian                 | int  
DP05_0046PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Asian Other Asian                 | int  
DP05_0047E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE One race Native Hawaiian and Other Pacific Is | int  
DP05_0047PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE One race Native Hawaiian and Other Pacific Is | int  
DP05_0048E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Native Hawaiian and Other Pacific | int  
DP05_0048PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Native Hawaiian and Other Pacific | int  
DP05_0049E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Native Hawaiian and Other Pacific | int  
DP05_0049PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Native Hawaiian and Other Pacific | int  
DP05_0050E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Native Hawaiian and Other Pacific | int  
DP05_0050PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Native Hawaiian and Other Pacific | int  
DP05_0051E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Native Hawaiian and Other Pacific | int  
DP05_0051PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! RACE One race Native Hawaiian and Other Pacific | int  
DP05_0052E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE One race Some other race                      | int  
DP05_0052PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE One race Some other race                      | int  
DP05_0053E   | ACS DEMOGRAPHIC AND HOUSING ES | !! RACE Two or more races                                | int  
DP05_0053PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! RACE Two or more races                                | int  
DP05_0054E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE Two or more races White and Black or African  | int  
DP05_0054PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE Two or more races White and Black or African  | int  
DP05_0055E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE Two or more races White and American Indian a | int  
DP05_0055PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE Two or more races White and American Indian a | int  
DP05_0056E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE Two or more races White and Asian             | int  
DP05_0056PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE Two or more races White and Asian             | int  
DP05_0057E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE Two or more races Black or African American a | int  
DP05_0057PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! RACE Two or more races Black or African American a | int  
DP05_0058E   | ACS DEMOGRAPHIC AND HOUSING ES | !! Race alone or in combination with one or more other r | int  
DP05_0058PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! Race alone or in combination with one or more other r | int  
DP05_0059E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! Race alone or in combination with one or more othe | int  
DP05_0059PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! Race alone or in combination with one or more othe | int  
DP05_0060E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! Race alone or in combination with one or more othe | int  
DP05_0060PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! Race alone or in combination with one or more othe | int  
DP05_0061E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! Race alone or in combination with one or more othe | int  
DP05_0061PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! Race alone or in combination with one or more othe | int  
DP05_0062E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! Race alone or in combination with one or more othe | int  
DP05_0062PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! Race alone or in combination with one or more othe | int  
DP05_0063E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! Race alone or in combination with one or more othe | int  
DP05_0063PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! Race alone or in combination with one or more othe | int  
DP05_0064E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! Race alone or in combination with one or more othe | int  
DP05_0064PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! Race alone or in combination with one or more othe | int  
DP05_0065E   | ACS DEMOGRAPHIC AND HOUSING ES | !! HISPANIC OR LATINO AND RACE Total population          | int  
DP05_0065PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! HISPANIC OR LATINO AND RACE Total population          | int  
DP05_0066E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! HISPANIC OR LATINO AND RACE Total population Hispa | int  
DP05_0066PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! HISPANIC OR LATINO AND RACE Total population Hispa | int  
DP05_0067E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population Hi | int  
DP05_0067PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population Hi | int  
DP05_0068E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population Hi | int  
DP05_0068PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population Hi | int  
DP05_0069E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population Hi | int  
DP05_0069PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population Hi | int  
DP05_0070E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population Hi | int  
DP05_0070PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population Hi | int  
DP05_0071E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! HISPANIC OR LATINO AND RACE Total population Not H | int  
DP05_0071PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! HISPANIC OR LATINO AND RACE Total population Not H | int  
DP05_0072E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0072PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0073E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0073PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0074E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0074PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0075E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0075PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0076E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0076PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0077E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0077PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0078E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0078PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! HISPANIC OR LATINO AND RACE Total population No | int  
DP05_0079E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! !! HISPANIC OR LATINO AND RACE Total population | int  
DP05_0079PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! !! HISPANIC OR LATINO AND RACE Total population | int  
DP05_0080E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! !! HISPANIC OR LATINO AND RACE Total population | int  
DP05_0080PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! !! !! HISPANIC OR LATINO AND RACE Total population | int  
DP05_0081E   | ACS DEMOGRAPHIC AND HOUSING ES | Total housing units                                      | int  
DP05_0081PE  | ACS DEMOGRAPHIC AND HOUSING ES | Total housing units                                      | int  
DP05_0082E   | ACS DEMOGRAPHIC AND HOUSING ES | !! CITIZEN, VOTING AGE POPULATION Citizen, 18 and over p | int  
DP05_0082PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! CITIZEN, VOTING AGE POPULATION Citizen, 18 and over p | int  
DP05_0083E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! CITIZEN, VOTING AGE POPULATION Citizen, 18 and ove | int  
DP05_0083PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! CITIZEN, VOTING AGE POPULATION Citizen, 18 and ove | int  
DP05_0084E   | ACS DEMOGRAPHIC AND HOUSING ES | !! !! CITIZEN, VOTING AGE POPULATION Citizen, 18 and ove | int  
DP05_0084PE  | ACS DEMOGRAPHIC AND HOUSING ES | !! !! CITIZEN, VOTING AGE POPULATION Citizen, 18 and ove | int  
-------------------------------------------------------------------------------------------------------------------

After identifying the relevant variables, we download and describe the data, and compute the percent 65+ similarly to how we did so before, except now the computation is somewhat simpler:


In [6]:
county65plus = censusdata.download('acs5', 2015, censusdata.censusgeo([('county', '*')]),
                                   ['DP05_0001E', 'DP05_0014PE', 'DP05_0015PE', 'DP05_0016PE',],
                                   tabletype='profile')
county65plus.describe()


Out[6]:
DP05_0001E DP05_0014PE DP05_0015PE DP05_0016PE
count 3.22e+03 3220.00 3220.00 3220.00
mean 9.94e+04 9.61 5.30 2.19
std 3.19e+05 2.43 1.63 0.93
min 8.50e+01 2.10 0.00 0.00
25% 1.12e+04 8.10 4.20 1.60
50% 2.60e+04 9.40 5.10 2.00
75% 6.64e+04 10.80 6.20 2.60
max 1.00e+07 32.50 14.90 9.10

In [7]:
county65plus['percent_65plus'] = (county65plus['DP05_0014PE'] + county65plus['DP05_0015PE']
                                  + county65plus['DP05_0016PE'])
county65plus = county65plus[['DP05_0001E', 'percent_65plus']]
county65plus = county65plus.rename(columns={'DP05_0001E': 'population_size'})
county65plus.describe()


Out[7]:
population_size percent_65plus
count 3.22e+03 3220.00
mean 9.94e+04 17.10
std 3.19e+05 4.39
min 8.50e+01 3.30
25% 1.12e+04 14.30
50% 2.60e+04 16.80
75% 6.64e+04 19.40
max 1.00e+07 50.90

Finally, we identify the top 30 counties for population aged 65+, and export data for all counties to CSV:


In [8]:
county65plus.sort_values('percent_65plus', ascending=False, inplace=True)
county65plus.head(30)


Out[8]:
population_size percent_65plus
Sumter County, Florida: Summary level: 050, state:12> county:119 108501 50.9
Charlotte County, Florida: Summary level: 050, state:12> county:015 165783 36.8
Mineral County, Colorado: Summary level: 050, state:08> county:079 733 36.6
Hooker County, Nebraska: Summary level: 050, state:31> county:091 681 35.8
La Paz County, Arizona: Summary level: 050, state:04> county:012 20335 35.2
Citrus County, Florida: Summary level: 050, state:12> county:017 139654 34.4
Wheeler County, Oregon: Summary level: 050, state:41> county:069 1348 34.3
Highland County, Virginia: Summary level: 050, state:51> county:091 2244 34.0
Alcona County, Michigan: Summary level: 050, state:26> county:001 10550 34.0
Real County, Texas: Summary level: 050, state:48> county:385 3356 34.0
Lancaster County, Virginia: Summary level: 050, state:51> county:103 11129 33.9
Sierra County, New Mexico: Summary level: 050, state:35> county:051 11615 33.9
Llano County, Texas: Summary level: 050, state:48> county:299 19323 33.6
Highlands County, Florida: Summary level: 050, state:12> county:055 98328 33.3
Sarasota County, Florida: Summary level: 050, state:12> county:115 392038 33.1
Northumberland County, Virginia: Summary level: 050, state:51> county:133 12304 33.1
McIntosh County, North Dakota: Summary level: 050, state:38> county:051 2759 33.1
Catron County, New Mexico: Summary level: 050, state:35> county:003 3583 32.7
Towns County, Georgia: Summary level: 050, state:13> county:281 10800 31.9
Hickory County, Missouri: Summary level: 050, state:29> county:085 9335 31.5
Ontonagon County, Michigan: Summary level: 050, state:26> county:131 6298 30.6
Union County, Georgia: Summary level: 050, state:13> county:291 21725 30.5
Curry County, Oregon: Summary level: 050, state:41> county:015 22338 30.4
Hinsdale County, Colorado: Summary level: 050, state:08> county:053 874 30.1
Jefferson County, Washington: Summary level: 050, state:53> county:031 30083 30.1
McMullen County, Texas: Summary level: 050, state:48> county:311 778 29.7
Keweenaw County, Michigan: Summary level: 050, state:26> county:083 2198 29.7
McPherson County, South Dakota: Summary level: 050, state:46> county:089 2263 29.7
Indian River County, Florida: Summary level: 050, state:12> county:061 142866 29.6
Baxter County, Arkansas: Summary level: 050, state:05> county:005 41040 29.5

In [9]:
censusdata.exportcsv('county65plus.csv', county65plus)