import os
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from IPython.core.display import display, HTML
%matplotlib inline
from zipfile import ZipFile
import geopandas as gpd
from shapely.geometry import Point
import folium
import json
pd.options.display.max_columns = None
display(HTML("<style>.container { width:100% !important; }</style>"))
In this notebook, I use geospatial data provided by the United States Census Bureau. The US Census Bureau hosts a massive amount of data. As a result, they've made a lot of different interfaces to help you find data. I've used the American Fact Finder interface to download the 2011-2015 American Community Survey Estimates. To get this data set, you can get it from the data section of this notebook's github repository, or you can go to the American Fact Finder site and select:
It's kind of a chore to find data sets you found in the past unless you remember the data set ID or table name, but that's the cost of having access to such a massive trove of data.
ZIP_PATH = os.path.join('data', 'census', 'ACS_15_5YR_DP05.zip')
with ZipFile(ZIP_PATH) as zip_file:
with zip_file.open('ACS_15_5YR_DP05_with_ann.csv') as my_zipped_csv:
il_acs_15 = pd.read_csv(my_zipped_csv, header=1)
il_acs_15.head()
Id | Id2 | Geography | Estimate; SEX AND AGE - Total population | Margin of Error; SEX AND AGE - Total population | Percent; SEX AND AGE - Total population | Percent Margin of Error; SEX AND AGE - Total population | Estimate; SEX AND AGE - Total population - Male | Margin of Error; SEX AND AGE - Total population - Male | Percent; SEX AND AGE - Total population - Male | Percent Margin of Error; SEX AND AGE - Total population - Male | Estimate; SEX AND AGE - Total population - Female | Margin of Error; SEX AND AGE - Total population - Female | Percent; SEX AND AGE - Total population - Female | Percent Margin of Error; SEX AND AGE - Total population - Female | Estimate; SEX AND AGE - Under 5 years | Margin of Error; SEX AND AGE - Under 5 years | Percent; SEX AND AGE - Under 5 years | Percent Margin of Error; SEX AND AGE - Under 5 years | Estimate; SEX AND AGE - 5 to 9 years | Margin of Error; SEX AND AGE - 5 to 9 years | Percent; SEX AND AGE - 5 to 9 years | Percent Margin of Error; SEX AND AGE - 5 to 9 years | Estimate; SEX AND AGE - 10 to 14 years | Margin of Error; SEX AND AGE - 10 to 14 years | Percent; SEX AND AGE - 10 to 14 years | Percent Margin of Error; SEX AND AGE - 10 to 14 years | Estimate; SEX AND AGE - 15 to 19 years | Margin of Error; SEX AND AGE - 15 to 19 years | Percent; SEX AND AGE - 15 to 19 years | Percent Margin of Error; SEX AND AGE - 15 to 19 years | Estimate; SEX AND AGE - 20 to 24 years | Margin of Error; SEX AND AGE - 20 to 24 years | Percent; SEX AND AGE - 20 to 24 years | Percent Margin of Error; SEX AND AGE - 20 to 24 years | Estimate; SEX AND AGE - 25 to 34 years | Margin of Error; SEX AND AGE - 25 to 34 years | Percent; SEX AND AGE - 25 to 34 years | Percent Margin of Error; SEX AND AGE - 25 to 34 years | Estimate; SEX AND AGE - 35 to 44 years | Margin of Error; SEX AND AGE - 35 to 44 years | Percent; SEX AND AGE - 35 to 44 years | Percent Margin of Error; SEX AND AGE - 35 to 44 years | Estimate; SEX AND AGE - 45 to 54 years | Margin of Error; SEX AND AGE - 45 to 54 years | Percent; SEX AND AGE - 45 to 54 years | Percent Margin of Error; SEX AND AGE - 45 to 54 years | Estimate; SEX AND AGE - 55 to 59 years | Margin of Error; SEX AND AGE - 55 to 59 years | Percent; SEX AND AGE - 55 to 59 years | Percent Margin of Error; SEX AND AGE - 55 to 59 years | Estimate; SEX AND AGE - 60 to 64 years | Margin of Error; SEX AND AGE - 60 to 64 years | Percent; SEX AND AGE - 60 to 64 years | Percent Margin of Error; SEX AND AGE - 60 to 64 years | Estimate; SEX AND AGE - 65 to 74 years | Margin of Error; SEX AND AGE - 65 to 74 years | Percent; SEX AND AGE - 65 to 74 years | Percent Margin of Error; SEX AND AGE - 65 to 74 years | Estimate; SEX AND AGE - 75 to 84 years | Margin of Error; SEX AND AGE - 75 to 84 years | Percent; SEX AND AGE - 75 to 84 years | Percent Margin of Error; SEX AND AGE - 75 to 84 years | Estimate; SEX AND AGE - 85 years and over | Margin of Error; SEX AND AGE - 85 years and over | Percent; SEX AND AGE - 85 years and over | Percent Margin of Error; SEX AND AGE - 85 years and over | Estimate; SEX AND AGE - Median age (years) | Margin of Error; SEX AND AGE - Median age (years) | Percent; SEX AND AGE - Median age (years) | Percent Margin of Error; SEX AND AGE - Median age (years) | Estimate; SEX AND AGE - 18 years and over | Margin of Error; SEX AND AGE - 18 years and over | Percent; SEX AND AGE - 18 years and over | Percent Margin of Error; SEX AND AGE - 18 years and over | Estimate; SEX AND AGE - 21 years and over | Margin of Error; SEX AND AGE - 21 years and over | Percent; SEX AND AGE - 21 years and over | Percent Margin of Error; SEX AND AGE - 21 years and over | Estimate; SEX AND AGE - 62 years and over | Margin of Error; SEX AND AGE - 62 years and over | Percent; SEX AND AGE - 62 years and over | Percent Margin of Error; SEX AND AGE - 62 years and over | Estimate; SEX AND AGE - 65 years and over | Margin of Error; SEX AND AGE - 65 years and over | Percent; SEX AND AGE - 65 years and over | Percent Margin of Error; SEX AND AGE - 65 years and over | Estimate; SEX AND AGE - 18 years and over.1 | Margin of Error; SEX AND AGE - 18 years and over.1 | Percent; SEX AND AGE - 18 years and over.1 | Percent Margin of Error; SEX AND AGE - 18 years and over.1 | Estimate; SEX AND AGE - 18 years and over - Male | Margin of Error; SEX AND AGE - 18 years and over - Male | Percent; SEX AND AGE - 18 years and over - Male | Percent Margin of Error; SEX AND AGE - 18 years and over - Male | Estimate; SEX AND AGE - 18 years and over - Female | Margin of Error; SEX AND AGE - 18 years and over - Female | Percent; SEX AND AGE - 18 years and over - Female | Percent Margin of Error; SEX AND AGE - 18 years and over - Female | Estimate; SEX AND AGE - 65 years and over.1 | Margin of Error; SEX AND AGE - 65 years and over.1 | Percent; SEX AND AGE - 65 years and over.1 | Percent Margin of Error; SEX AND AGE - 65 years and over.1 | Estimate; SEX AND AGE - 65 years and over - Male | Margin of Error; SEX AND AGE - 65 years and over - Male | Percent; SEX AND AGE - 65 years and over - Male | Percent Margin of Error; SEX AND AGE - 65 years and over - Male | Estimate; SEX AND AGE - 65 years and over - Female | Margin of Error; SEX AND AGE - 65 years and over - Female | Percent; SEX AND AGE - 65 years and over - Female | Percent Margin of Error; SEX AND AGE - 65 years and over - Female | Estimate; RACE - Total population | Margin of Error; RACE - Total population | Percent; RACE - Total population | Percent Margin of Error; RACE - Total population | Estimate; RACE - Total population - One race | Margin of Error; RACE - Total population - One race | Percent; RACE - Total population - One race | Percent Margin of Error; RACE - Total population - One race | Estimate; RACE - Total population - Two or more races | Margin of Error; RACE - Total population - Two or more races | Percent; RACE - Total population - Two or more races | Percent Margin of Error; RACE - Total population - Two or more races | Estimate; RACE - One race | Margin of Error; RACE - One race | Percent; RACE - One race | Percent Margin of Error; RACE - One race | Estimate; RACE - One race - White | Margin of Error; RACE - One race - White | Percent; RACE - One race - White | Percent Margin of Error; RACE - One race - White | Estimate; RACE - One race - Black or African American | Margin of Error; RACE - One race - Black or African American | Percent; RACE - One race - Black or African American | Percent Margin of Error; RACE - One race - Black or African American | Estimate; RACE - One race - American Indian and Alaska Native | Margin of Error; RACE - One race - American Indian and Alaska Native | Percent; RACE - One race - American Indian and Alaska Native | Percent Margin of Error; RACE - One race - American Indian and Alaska Native | Estimate; RACE - One race - American Indian and Alaska Native - Cherokee tribal grouping | Margin of Error; RACE - One race - American Indian and Alaska Native - Cherokee tribal grouping | Percent; RACE - One race - American Indian and Alaska Native - Cherokee tribal grouping | Percent Margin of Error; RACE - One race - American Indian and Alaska Native - Cherokee tribal grouping | Estimate; RACE - One race - American Indian and Alaska Native - Chippewa tribal grouping | Margin of Error; RACE - One race - American Indian and Alaska Native - Chippewa tribal grouping | Percent; RACE - One race - American Indian and Alaska Native - Chippewa tribal grouping | Percent Margin of Error; RACE - One race - American Indian and Alaska Native - Chippewa tribal grouping | Estimate; RACE - One race - American Indian and Alaska Native - Navajo tribal grouping | Margin of Error; RACE - One race - American Indian and Alaska Native - Navajo tribal grouping | Percent; RACE - One race - American Indian and Alaska Native - Navajo tribal grouping | Percent Margin of Error; RACE - One race - American Indian and Alaska Native - Navajo tribal grouping | Estimate; RACE - One race - American Indian and Alaska Native - Sioux tribal grouping | Margin of Error; RACE - One race - American Indian and Alaska Native - Sioux tribal grouping | Percent; RACE - One race - American Indian and Alaska Native - Sioux tribal grouping | Percent Margin of Error; RACE - One race - American Indian and Alaska Native - Sioux tribal grouping | Estimate; RACE - One race - Asian | Margin of Error; RACE - One race - Asian | Percent; RACE - One race - Asian | Percent Margin of Error; RACE - One race - Asian | Estimate; RACE - One race - Asian - Asian Indian | Margin of Error; RACE - One race - Asian - Asian Indian | Percent; RACE - One race - Asian - Asian Indian | Percent Margin of Error; RACE - One race - Asian - Asian Indian | Estimate; RACE - One race - Asian - Chinese | Margin of Error; RACE - One race - Asian - Chinese | Percent; RACE - One race - Asian - Chinese | Percent Margin of Error; RACE - One race - Asian - Chinese | Estimate; RACE - One race - Asian - Filipino | Margin of Error; RACE - One race - Asian - Filipino | Percent; RACE - One race - Asian - Filipino | Percent Margin of Error; RACE - One race - Asian - Filipino | Estimate; RACE - One race - Asian - Japanese | Margin of Error; RACE - One race - Asian - Japanese | Percent; RACE - One race - Asian - Japanese | Percent Margin of Error; RACE - One race - Asian - Japanese | Estimate; RACE - One race - Asian - Korean | Margin of Error; RACE - One race - Asian - Korean | Percent; RACE - One race - Asian - Korean | Percent Margin of Error; RACE - One race - Asian - Korean | Estimate; RACE - One race - Asian - Vietnamese | Margin of Error; RACE - One race - Asian - Vietnamese | Percent; RACE - One race - Asian - Vietnamese | Percent Margin of Error; RACE - One race - Asian - Vietnamese | Estimate; RACE - One race - Asian - Other Asian | Margin of Error; RACE - One race - Asian - Other Asian | Percent; RACE - One race - Asian - Other Asian | Percent Margin of Error; RACE - One race - Asian - Other Asian | Estimate; RACE - One race - Native Hawaiian and Other Pacific Islander | Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander | Percent; RACE - One race - Native Hawaiian and Other Pacific Islander | Percent Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander | Estimate; RACE - One race - Native Hawaiian and Other Pacific Islander - Native Hawaiian | Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Native Hawaiian | Percent; RACE - One race - Native Hawaiian and Other Pacific Islander - Native Hawaiian | Percent Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Native Hawaiian | Estimate; RACE - One race - Native Hawaiian and Other Pacific Islander - Guamanian or Chamorro | Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Guamanian or Chamorro | Percent; RACE - One race - Native Hawaiian and Other Pacific Islander - Guamanian or Chamorro | Percent Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Guamanian or Chamorro | Estimate; RACE - One race - Native Hawaiian and Other Pacific Islander - Samoan | Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Samoan | Percent; RACE - One race - Native Hawaiian and Other Pacific Islander - Samoan | Percent Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Samoan | Estimate; RACE - One race - Native Hawaiian and Other Pacific Islander - Other Pacific Islander | Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Other Pacific Islander | Percent; RACE - One race - Native Hawaiian and Other Pacific Islander - Other Pacific Islander | Percent Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Other Pacific Islander | Estimate; RACE - One race - Some other race | Margin of Error; RACE - One race - Some other race | Percent; RACE - One race - Some other race | Percent Margin of Error; RACE - One race - Some other race | Estimate; RACE - Two or more races | Margin of Error; RACE - Two or more races | Percent; RACE - Two or more races | Percent Margin of Error; RACE - Two or more races | Estimate; RACE - Two or more races - White and Black or African American | Margin of Error; RACE - Two or more races - White and Black or African American | Percent; RACE - Two or more races - White and Black or African American | Percent Margin of Error; RACE - Two or more races - White and Black or African American | Estimate; RACE - Two or more races - White and American Indian and Alaska Native | Margin of Error; RACE - Two or more races - White and American Indian and Alaska Native | Percent; RACE - Two or more races - White and American Indian and Alaska Native | Percent Margin of Error; RACE - Two or more races - White and American Indian and Alaska Native | Estimate; RACE - Two or more races - White and Asian | Margin of Error; RACE - Two or more races - White and Asian | Percent; RACE - Two or more races - White and Asian | Percent Margin of Error; RACE - Two or more races - White and Asian | Estimate; RACE - Two or more races - Black or African American and American Indian and Alaska Native | Margin of Error; RACE - Two or more races - Black or African American and American Indian and Alaska Native | Percent; RACE - Two or more races - Black or African American and American Indian and Alaska Native | Percent Margin of Error; RACE - Two or more races - Black or African American and American Indian and Alaska Native | Estimate; RACE - Race alone or in combination with one or more other races - Total population | Margin of Error; RACE - Race alone or in combination with one or more other races - Total population | Percent; RACE - Race alone or in combination with one or more other races - Total population | Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population | Estimate; RACE - Race alone or in combination with one or more other races - Total population - White | Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - White | Percent; RACE - Race alone or in combination with one or more other races - Total population - White | Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - White | Estimate; RACE - Race alone or in combination with one or more other races - Total population - Black or African American | Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Black or African American | Percent; RACE - Race alone or in combination with one or more other races - Total population - Black or African American | Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Black or African American | Estimate; RACE - Race alone or in combination with one or more other races - Total population - American Indian and Alaska Native | Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - American Indian and Alaska Native | Percent; RACE - Race alone or in combination with one or more other races - Total population - American Indian and Alaska Native | Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - American Indian and Alaska Native | Estimate; RACE - Race alone or in combination with one or more other races - Total population - Asian | Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Asian | Percent; RACE - Race alone or in combination with one or more other races - Total population - Asian | Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Asian | Estimate; RACE - Race alone or in combination with one or more other races - Total population - Native Hawaiian and Other Pacific Islander | Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Native Hawaiian and Other Pacific Islander | Percent; RACE - Race alone or in combination with one or more other races - Total population - Native Hawaiian and Other Pacific Islander | Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Native Hawaiian and Other Pacific Islander | Estimate; RACE - Race alone or in combination with one or more other races - Total population - Some other race | Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Some other race | Percent; RACE - Race alone or in combination with one or more other races - Total population - Some other race | Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Some other race | Estimate; HISPANIC OR LATINO AND RACE - Total population | Margin of Error; HISPANIC OR LATINO AND RACE - Total population | Percent; HISPANIC OR LATINO AND RACE - Total population | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population | Estimate; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) | Percent; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) | Estimate; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Mexican | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Mexican | Percent; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Mexican | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Mexican | Estimate; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Puerto Rican | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Puerto Rican | Percent; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Puerto Rican | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Puerto Rican | Estimate; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Cuban | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Cuban | Percent; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Cuban | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Cuban | Estimate; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Other Hispanic or Latino | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Other Hispanic or Latino | Percent; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Other Hispanic or Latino | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Other Hispanic or Latino | Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino | Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino | Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - White alone | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - White alone | Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - White alone | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - White alone | Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Black or African American alone | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Black or African American alone | Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Black or African American alone | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Black or African American alone | Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - American Indian and Alaska Native alone | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - American Indian and Alaska Native alone | Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - American Indian and Alaska Native alone | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - American Indian and Alaska Native alone | Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Asian alone | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Asian alone | Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Asian alone | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Asian alone | Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Native Hawaiian and Other Pacific Islander alone | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Native Hawaiian and Other Pacific Islander alone | Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Native Hawaiian and Other Pacific Islander alone | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Native Hawaiian and Other Pacific Islander alone | Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Some other race alone | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Some other race alone | Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Some other race alone | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Some other race alone | Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races | Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races | Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races including Some other race | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races including Some other race | Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races including Some other race | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races including Some other race | Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races excluding Some other race, and Three or more races | Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races excluding Some other race, and Three or more races | Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races excluding Some other race, and Three or more races | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races excluding Some other race, and Three or more races | Estimate; HISPANIC OR LATINO AND RACE - Total housing units | Margin of Error; HISPANIC OR LATINO AND RACE - Total housing units | Percent; HISPANIC OR LATINO AND RACE - Total housing units | Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total housing units | Estimate; CITIZEN, VOTING AGE POPULATION - Citizen, 18 and over population | Margin of Error; CITIZEN, VOTING AGE POPULATION - Citizen, 18 and over population | Percent; CITIZEN, VOTING AGE POPULATION - Citizen, 18 and over population | Percent Margin of Error; CITIZEN, VOTING AGE POPULATION - Citizen, 18 and over population | Estimate; CITIZEN, VOTING AGE POPULATION - Citizen, 18 and over population - Male | Margin of Error; CITIZEN, VOTING AGE POPULATION - Citizen, 18 and over population - Male | Percent; CITIZEN, VOTING AGE POPULATION - Citizen, 18 and over population - Male | Percent Margin of Error; CITIZEN, VOTING AGE POPULATION - Citizen, 18 and over population - Male | Estimate; CITIZEN, VOTING AGE POPULATION - Citizen, 18 and over population - Female | Margin of Error; CITIZEN, VOTING AGE POPULATION - Citizen, 18 and over population - Female | Percent; CITIZEN, VOTING AGE POPULATION - Citizen, 18 and over population - Female | Percent Margin of Error; CITIZEN, VOTING AGE POPULATION - Citizen, 18 and over population - Female | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1400000US17031010100 | 17031010100 | Census Tract 101, Cook County, Illinois | 4106 | 468 | 4106 | (X) | 1891 | 267 | 46.1 | 4.7 | 2215 | 338 | 53.9 | 4.7 | 268 | 89 | 6.5 | 2.1 | 159 | 93 | 3.9 | 2.1 | 207 | 137 | 5.0 | 3.2 | 229 | 146 | 5.6 | 3.2 | 249 | 127 | 6.1 | 3.0 | 736 | 264 | 17.9 | 5.9 | 881 | 215 | 21.5 | 5.2 | 543 | 170 | 13.2 | 4.1 | 436 | 167 | 10.6 | 4.1 | 227 | 105 | 5.5 | 2.4 | 164 | 84 | 4.0 | 2.1 | 7 | 16 | 0.2 | 0.4 | 0 | 11 | 0.0 | 0.7 | 36.6 | 2.2 | (X) | (X) | 3316 | 338 | 80.8 | 5.2 | 3217 | 317 | 78.3 | 5.3 | 297 | 115 | 7.2 | 2.9 | 171 | 83 | 4.2 | 2.1 | 3316 | 338 | 3316 | (X) | 1536 | 236 | 46.3 | 5.5 | 1780 | 262 | 53.7 | 5.5 | 171 | 83 | 171 | (X) | 44 | 46 | 25.7 | 21.3 | 127 | 69 | 74.3 | 21.3 | 4106 | 468 | 4106 | (X) | 3993 | 478 | 97.2 | 2.0 | 113 | 83 | 2.8 | 2.0 | 3993 | 478 | 97.2 | 2.0 | 2186 | 414 | 53.2 | 8.2 | 1586 | 365 | 38.6 | 8.1 | 0 | 11 | 0.0 | 0.7 | 0 | 11 | 0.0 | 0.7 | 0 | 11 | 0.0 | 0.7 | 0 | 11 | 0.0 | 0.7 | 0 | 11 | 0.0 | 0.7 | 155 | 227 | 3.8 | 5.4 | 0 | 11 | 0.0 | 0.7 | 0 | 11 | 0.0 | 0.7 | 138 | 225 | 3.4 | 5.3 | 0 | 11 | 0.0 | 0.7 | 3 | 8 | 0.1 | 0.2 | 0 | 11 | 0.0 | 0.7 | 14 | 21 | 0.3 | 0.5 | 0 | 11 | 0.0 | 0.7 | 0 | 11 | 0.0 | 0.7 | 0 | 11 | 0.0 | 0.7 | 0 | 11 | 0.0 | 0.7 | 0 | 11 | 0.0 | 0.7 | 66 | 47 | 1.6 | 1.2 | 113 | 83 | 2.8 | 2.0 | 46 | 57 | 1.1 | 1.4 | 0 | 11 | 0.0 | 0.7 | 29 | 47 | 0.7 | 1.1 | 14 | 22 | 0.3 | 0.5 | 4106 | 468 | 4106 | (X) | 2271 | 422 | 55.3 | 8.5 | 1670 | 355 | 40.7 | 7.9 | 24 | 27 | 0.6 | 0.7 | 184 | 232 | 4.5 | 5.5 | 0 | 11 | 0.0 | 0.7 | 80 | 57 | 1.9 | 1.4 | 4106 | 468 | 4106 | (X) | 475 | 317 | 11.6 | 7.1 | 271 | 287 | 6.6 | 6.7 | 114 | 137 | 2.8 | 3.2 | 0 | 11 | 0.0 | 0.7 | 90 | 85 | 2.2 | 2.1 | 3631 | 421 | 88.4 | 7.1 | 1830 | 321 | 44.6 | 7.4 | 1519 | 323 | 37.0 | 7.6 | 0 | 11 | 0.0 | 0.7 | 155 | 227 | 3.8 | 5.4 | 0 | 11 | 0.0 | 0.7 | 14 | 23 | 0.3 | 0.6 | 113 | 83 | 2.8 | 2.0 | 14 | 23 | 0.3 | 0.6 | 99 | 79 | 2.4 | 2.0 | 2625 | 41 | (X) | (X) | 2989 | 340 | 2989 | (X) | 1315 | 233 | 44.0 | 5.8 | 1674 | 254 | 56.0 | 5.8 |
1 | 1400000US17031010201 | 17031010201 | Census Tract 102.01, Cook County, Illinois | 7229 | 942 | 7229 | (X) | 3554 | 564 | 49.2 | 3.6 | 3675 | 509 | 50.8 | 3.6 | 681 | 226 | 9.4 | 2.6 | 441 | 190 | 6.1 | 2.4 | 277 | 143 | 3.8 | 1.8 | 396 | 143 | 5.5 | 1.8 | 610 | 246 | 8.4 | 3.1 | 1688 | 418 | 23.4 | 4.8 | 1103 | 300 | 15.3 | 3.8 | 1018 | 252 | 14.1 | 3.5 | 281 | 142 | 3.9 | 1.8 | 351 | 165 | 4.9 | 2.4 | 190 | 123 | 2.6 | 1.7 | 156 | 110 | 2.2 | 1.6 | 37 | 43 | 0.5 | 0.6 | 31.8 | 2.6 | (X) | (X) | 5570 | 707 | 77.1 | 3.8 | 5174 | 624 | 71.6 | 4.4 | 527 | 194 | 7.3 | 2.8 | 383 | 163 | 5.3 | 2.4 | 5570 | 707 | 5570 | (X) | 2695 | 443 | 48.4 | 4.0 | 2875 | 388 | 51.6 | 4.0 | 383 | 163 | 383 | (X) | 136 | 81 | 35.5 | 13.5 | 247 | 110 | 64.5 | 13.5 | 7229 | 942 | 7229 | (X) | 6972 | 924 | 96.4 | 2.3 | 257 | 169 | 3.6 | 2.3 | 6972 | 924 | 96.4 | 2.3 | 3388 | 692 | 46.9 | 7.6 | 3295 | 721 | 45.6 | 7.8 | 26 | 42 | 0.4 | 0.6 | 0 | 15 | 0.0 | 0.4 | 0 | 15 | 0.0 | 0.4 | 0 | 15 | 0.0 | 0.4 | 0 | 15 | 0.0 | 0.4 | 223 | 178 | 3.1 | 2.4 | 112 | 155 | 1.5 | 2.1 | 11 | 19 | 0.2 | 0.3 | 88 | 85 | 1.2 | 1.2 | 12 | 19 | 0.2 | 0.3 | 0 | 15 | 0.0 | 0.4 | 0 | 15 | 0.0 | 0.4 | 0 | 15 | 0.0 | 0.4 | 0 | 15 | 0.0 | 0.4 | 0 | 15 | 0.0 | 0.4 | 0 | 15 | 0.0 | 0.4 | 0 | 15 | 0.0 | 0.4 | 0 | 15 | 0.0 | 0.4 | 40 | 38 | 0.6 | 0.5 | 257 | 169 | 3.6 | 2.3 | 51 | 62 | 0.7 | 0.8 | 86 | 140 | 1.2 | 1.9 | 62 | 70 | 0.9 | 1.0 | 11 | 18 | 0.2 | 0.3 | 7229 | 942 | 7229 | (X) | 3601 | 702 | 49.8 | 7.4 | 3390 | 724 | 46.9 | 7.8 | 123 | 146 | 1.7 | 2.0 | 285 | 193 | 3.9 | 2.6 | 11 | 18 | 0.2 | 0.3 | 76 | 77 | 1.1 | 1.1 | 7229 | 942 | 7229 | (X) | 1990 | 657 | 27.5 | 7.2 | 1744 | 633 | 24.1 | 7.2 | 53 | 64 | 0.7 | 0.9 | 104 | 120 | 1.4 | 1.7 | 89 | 72 | 1.2 | 1.0 | 5239 | 708 | 72.5 | 7.2 | 1538 | 255 | 21.3 | 4.5 | 3295 | 721 | 45.6 | 7.8 | 26 | 42 | 0.4 | 0.6 | 223 | 178 | 3.1 | 2.4 | 0 | 15 | 0.0 | 0.4 | 11 | 17 | 0.2 | 0.2 | 146 | 135 | 2.0 | 1.8 | 0 | 15 | 0.0 | 0.4 | 146 | 135 | 2.0 | 1.8 | 3007 | 66 | (X) | (X) | 3847 | 455 | 3847 | (X) | 1824 | 352 | 47.4 | 5.6 | 2023 | 261 | 52.6 | 5.6 |
2 | 1400000US17031010202 | 17031010202 | Census Tract 102.02, Cook County, Illinois | 2304 | 271 | 2304 | (X) | 1215 | 199 | 52.7 | 5.2 | 1089 | 163 | 47.3 | 5.2 | 197 | 86 | 8.6 | 3.5 | 113 | 72 | 4.9 | 3.0 | 67 | 48 | 2.9 | 2.0 | 76 | 50 | 3.3 | 2.1 | 171 | 99 | 7.4 | 3.9 | 378 | 111 | 16.4 | 4.6 | 361 | 101 | 15.7 | 4.6 | 260 | 99 | 11.3 | 4.5 | 100 | 59 | 4.3 | 2.5 | 222 | 94 | 9.6 | 3.7 | 174 | 74 | 7.6 | 2.9 | 120 | 76 | 5.2 | 3.2 | 65 | 39 | 2.8 | 1.7 | 37.8 | 4.0 | (X) | (X) | 1919 | 241 | 83.3 | 4.9 | 1836 | 227 | 79.7 | 4.8 | 483 | 190 | 21.0 | 7.2 | 359 | 129 | 15.6 | 5.1 | 1919 | 241 | 1919 | (X) | 1006 | 193 | 52.4 | 6.1 | 913 | 138 | 47.6 | 6.1 | 359 | 129 | 359 | (X) | 151 | 104 | 42.1 | 18.6 | 208 | 71 | 57.9 | 18.6 | 2304 | 271 | 2304 | (X) | 2234 | 276 | 97.0 | 2.6 | 70 | 60 | 3.0 | 2.6 | 2234 | 276 | 97.0 | 2.6 | 1178 | 234 | 51.1 | 8.8 | 674 | 166 | 29.3 | 7.9 | 12 | 17 | 0.5 | 0.7 | 0 | 11 | 0.0 | 1.2 | 0 | 11 | 0.0 | 1.2 | 0 | 11 | 0.0 | 1.2 | 0 | 11 | 0.0 | 1.2 | 185 | 184 | 8.0 | 7.5 | 105 | 169 | 4.6 | 7.1 | 16 | 22 | 0.7 | 0.9 | 18 | 22 | 0.8 | 0.9 | 0 | 11 | 0.0 | 1.2 | 0 | 11 | 0.0 | 1.2 | 0 | 11 | 0.0 | 1.2 | 46 | 70 | 2.0 | 3.0 | 0 | 11 | 0.0 | 1.2 | 0 | 11 | 0.0 | 1.2 | 0 | 11 | 0.0 | 1.2 | 0 | 11 | 0.0 | 1.2 | 0 | 11 | 0.0 | 1.2 | 185 | 132 | 8.0 | 5.5 | 70 | 60 | 3.0 | 2.6 | 2 | 9 | 0.1 | 0.4 | 27 | 42 | 1.2 | 1.8 | 5 | 9 | 0.2 | 0.4 | 0 | 11 | 0.0 | 1.2 | 2304 | 271 | 2304 | (X) | 1229 | 241 | 53.3 | 9.0 | 676 | 167 | 29.3 | 8.0 | 58 | 53 | 2.5 | 2.3 | 190 | 186 | 8.2 | 7.5 | 0 | 11 | 0.0 | 1.2 | 221 | 138 | 9.6 | 5.7 | 2304 | 271 | 2304 | (X) | 609 | 210 | 26.4 | 7.8 | 428 | 166 | 18.6 | 6.6 | 51 | 57 | 2.2 | 2.5 | 15 | 25 | 0.7 | 1.1 | 115 | 103 | 5.0 | 4.3 | 1695 | 235 | 73.6 | 7.8 | 817 | 214 | 35.5 | 9.2 | 648 | 162 | 28.1 | 7.7 | 0 | 11 | 0.0 | 1.2 | 177 | 182 | 7.7 | 7.4 | 0 | 11 | 0.0 | 1.2 | 0 | 11 | 0.0 | 1.2 | 53 | 53 | 2.3 | 2.3 | 19 | 30 | 0.8 | 1.3 | 34 | 42 | 1.5 | 1.8 | 1227 | 35 | (X) | (X) | 1499 | 201 | 1499 | (X) | 827 | 166 | 55.2 | 6.6 | 672 | 116 | 44.8 | 6.6 |
3 | 1400000US17031010300 | 17031010300 | Census Tract 103, Cook County, Illinois | 6077 | 694 | 6077 | (X) | 3095 | 457 | 50.9 | 3.9 | 2982 | 377 | 49.1 | 3.9 | 372 | 156 | 6.1 | 2.3 | 208 | 98 | 3.4 | 1.5 | 122 | 90 | 2.0 | 1.4 | 235 | 144 | 3.9 | 2.3 | 389 | 216 | 6.4 | 3.2 | 1156 | 294 | 19.0 | 4.5 | 882 | 243 | 14.5 | 3.8 | 1107 | 317 | 18.2 | 5.1 | 267 | 105 | 4.4 | 1.8 | 289 | 128 | 4.8 | 2.0 | 538 | 164 | 8.9 | 2.6 | 288 | 125 | 4.7 | 2.1 | 224 | 87 | 3.7 | 1.4 | 40.1 | 4.8 | (X) | (X) | 5259 | 585 | 86.5 | 3.7 | 5140 | 555 | 84.6 | 3.6 | 1241 | 275 | 20.4 | 4.3 | 1050 | 248 | 17.3 | 4.0 | 5259 | 585 | 5259 | (X) | 2642 | 388 | 50.2 | 4.3 | 2617 | 347 | 49.8 | 4.3 | 1050 | 248 | 1050 | (X) | 397 | 104 | 37.8 | 8.2 | 653 | 199 | 62.2 | 8.2 | 6077 | 694 | 6077 | (X) | 5910 | 697 | 97.3 | 1.7 | 167 | 99 | 2.7 | 1.7 | 5910 | 697 | 97.3 | 1.7 | 3478 | 518 | 57.2 | 8.0 | 1546 | 349 | 25.4 | 5.2 | 6 | 12 | 0.1 | 0.2 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 751 | 559 | 12.4 | 8.5 | 14 | 30 | 0.2 | 0.5 | 43 | 40 | 0.7 | 0.7 | 60 | 51 | 1.0 | 0.8 | 0 | 15 | 0.0 | 0.5 | 4 | 9 | 0.1 | 0.1 | 7 | 15 | 0.1 | 0.2 | 623 | 547 | 10.3 | 8.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 129 | 116 | 2.1 | 1.9 | 167 | 99 | 2.7 | 1.7 | 48 | 45 | 0.8 | 0.8 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 13 | 20 | 0.2 | 0.3 | 6077 | 694 | 6077 | (X) | 3606 | 511 | 59.3 | 7.9 | 1660 | 363 | 27.3 | 5.5 | 61 | 59 | 1.0 | 1.0 | 773 | 557 | 12.7 | 8.5 | 5 | 11 | 0.1 | 0.2 | 198 | 144 | 3.3 | 2.4 | 6077 | 694 | 6077 | (X) | 979 | 406 | 16.1 | 6.6 | 649 | 373 | 10.7 | 6.0 | 47 | 43 | 0.8 | 0.7 | 58 | 91 | 1.0 | 1.5 | 225 | 172 | 3.7 | 2.8 | 5098 | 722 | 83.9 | 6.6 | 2767 | 405 | 45.5 | 6.6 | 1476 | 343 | 24.3 | 5.2 | 6 | 12 | 0.1 | 0.2 | 751 | 559 | 12.4 | 8.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 98 | 67 | 1.6 | 1.1 | 0 | 15 | 0.0 | 0.5 | 98 | 67 | 1.6 | 1.1 | 3264 | 95 | (X) | (X) | 4150 | 496 | 4150 | (X) | 2069 | 351 | 49.9 | 5.1 | 2081 | 296 | 50.1 | 5.1 |
4 | 1400000US17031010400 | 17031010400 | Census Tract 104, Cook County, Illinois | 5011 | 544 | 5011 | (X) | 2067 | 279 | 41.2 | 4.7 | 2944 | 446 | 58.8 | 4.7 | 196 | 115 | 3.9 | 2.0 | 162 | 100 | 3.2 | 1.9 | 111 | 95 | 2.2 | 1.8 | 1164 | 242 | 23.2 | 4.5 | 810 | 271 | 16.2 | 5.0 | 720 | 216 | 14.4 | 4.4 | 639 | 225 | 12.8 | 3.8 | 422 | 111 | 8.4 | 2.2 | 198 | 116 | 4.0 | 2.3 | 209 | 105 | 4.2 | 2.2 | 311 | 165 | 6.2 | 3.4 | 21 | 25 | 0.4 | 0.5 | 48 | 44 | 1.0 | 0.9 | 25.4 | 2.2 | (X) | (X) | 4441 | 427 | 88.6 | 4.1 | 3086 | 339 | 61.6 | 4.8 | 531 | 185 | 10.6 | 3.9 | 380 | 166 | 7.6 | 3.4 | 4441 | 427 | 4441 | (X) | 1807 | 255 | 40.7 | 5.0 | 2634 | 369 | 59.3 | 5.0 | 380 | 166 | 380 | (X) | 154 | 105 | 40.5 | 17.3 | 226 | 103 | 59.5 | 17.3 | 5011 | 544 | 5011 | (X) | 4834 | 547 | 96.5 | 1.9 | 177 | 96 | 3.5 | 1.9 | 4834 | 547 | 96.5 | 1.9 | 3743 | 507 | 74.7 | 7.4 | 660 | 382 | 13.2 | 7.2 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 336 | 170 | 6.7 | 3.4 | 109 | 55 | 2.2 | 1.1 | 30 | 31 | 0.6 | 0.6 | 63 | 47 | 1.3 | 0.9 | 0 | 15 | 0.0 | 0.5 | 63 | 90 | 1.3 | 1.8 | 71 | 115 | 1.4 | 2.3 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 0 | 15 | 0.0 | 0.5 | 95 | 106 | 1.9 | 2.1 | 177 | 96 | 3.5 | 1.9 | 46 | 41 | 0.9 | 0.8 | 0 | 15 | 0.0 | 0.5 | 44 | 50 | 0.9 | 1.0 | 0 | 15 | 0.0 | 0.5 | 5011 | 544 | 5011 | (X) | 3865 | 513 | 77.1 | 7.4 | 719 | 385 | 14.3 | 7.2 | 27 | 31 | 0.5 | 0.6 | 421 | 190 | 8.4 | 3.8 | 14 | 22 | 0.3 | 0.5 | 155 | 120 | 3.1 | 2.4 | 5011 | 544 | 5011 | (X) | 417 | 179 | 8.3 | 3.3 | 289 | 145 | 5.8 | 2.8 | 27 | 28 | 0.5 | 0.6 | 37 | 60 | 0.7 | 1.2 | 64 | 80 | 1.3 | 1.6 | 4594 | 494 | 91.7 | 3.3 | 3467 | 479 | 69.2 | 7.5 | 613 | 361 | 12.2 | 6.8 | 0 | 15 | 0.0 | 0.5 | 328 | 170 | 6.5 | 3.4 | 0 | 15 | 0.0 | 0.5 | 36 | 57 | 0.7 | 1.1 | 150 | 89 | 3.0 | 1.8 | 47 | 53 | 0.9 | 1.1 | 103 | 68 | 2.1 | 1.3 | 2199 | 72 | (X) | (X) | 4144 | 403 | 4144 | (X) | 1642 | 204 | 39.6 | 4.9 | 2502 | 375 | 60.4 | 4.9 |
demographic_df = il_acs_15[['Id2',
'Percent; RACE - One race',
'Percent; RACE - One race - White',
'Percent; RACE - One race - Black or African American',
'Percent; RACE - One race - Asian',
'Percent; RACE - One race - Some other race',
'Percent; SEX AND AGE - Total population - Male',
'Percent; SEX AND AGE - Total population - Female',
'Percent; SEX AND AGE - Under 5 years',
'Percent; SEX AND AGE - 5 to 9 years',
'Percent; SEX AND AGE - 10 to 14 years',
'Percent; SEX AND AGE - 15 to 19 years',
'Percent; SEX AND AGE - 20 to 24 years',
'Percent; SEX AND AGE - 25 to 34 years',
'Percent; SEX AND AGE - 35 to 44 years',
'Percent; SEX AND AGE - 45 to 54 years',
'Percent; SEX AND AGE - 55 to 59 years',
'Percent; SEX AND AGE - 60 to 64 years',
'Percent; SEX AND AGE - 65 to 74 years',
'Percent; SEX AND AGE - 75 to 84 years',
'Percent; SEX AND AGE - 85 years and over']].copy()
demographic_df['Id2'] = demographic_df['Id2'].astype(str)
This demographic data is interesting, but if we want to map it out, we need a way to connect these demographic data points to their geographic locations. Fortunately, we can download a shapefile describing the geometries and names of all the census tracts in Chicago from Chicago's Data Portal (click menu, then click Download as a Shapefile).
ZIP_SHP_PATH = os.path.join('zip://', 'data', 'census', 'Boundaries - Census Tracts - 2010.zip')
coord_system = {'init': 'epsg:4326'}
chicago_census_tracts = gpd.read_file(ZIP_SHP_PATH).to_crs(coord_system)
chicago_census_tracts.plot(figsize=(15,10))
<matplotlib.axes._subplots.AxesSubplot at 0x2310b485e48>
chicago_census_tracts.head()
statefp10 | countyfp10 | tractce10 | namelsad10 | commarea | geoid10 | commarea_n | name10 | notes | geometry | |
---|---|---|---|---|---|---|---|---|---|---|
0 | 17 | 031 | 842400 | Census Tract 8424 | 44 | 17031842400 | 44.0 | 8424 | None | POLYGON ((-87.62404799998049 41.73021699998396... |
1 | 17 | 031 | 840300 | Census Tract 8403 | 59 | 17031840300 | 59.0 | 8403 | None | POLYGON ((-87.6860799999848 41.82295600001154,... |
2 | 17 | 031 | 841100 | Census Tract 8411 | 34 | 17031841100 | 34.0 | 8411 | None | POLYGON ((-87.62934700001183 41.8527970000265,... |
3 | 17 | 031 | 841200 | Census Tract 8412 | 31 | 17031841200 | 31.0 | 8412 | None | POLYGON ((-87.68813499997718 41.85569099999095... |
4 | 17 | 031 | 838200 | Census Tract 8382 | 28 | 17031838200 | 28.0 | 8382 | None | POLYGON ((-87.66781999997529 41.8741839999791,... |
To merge the geographic data to the demographic data, I need to find a column that both sets of data share. The geographic data's geoid10 column looks a lot like the Id2 column in the demographic data (and it does have the form of a census tract id). But before I can use this shared feature to merge these data sets, I need to make sure the values have the same type.
We see that in the geospatial data set, the geoid10 feature is of the 'object' type (which is pandas way of saying it's of the 'string' type), but in the demographic data, Id2, is of the 'integer' type.
chicago_census_tracts.info()
<class 'geopandas.geodataframe.GeoDataFrame'> RangeIndex: 801 entries, 0 to 800 Data columns (total 10 columns): statefp10 801 non-null object countyfp10 801 non-null object tractce10 801 non-null object namelsad10 801 non-null object commarea 801 non-null object geoid10 801 non-null object commarea_n 801 non-null float64 name10 801 non-null object notes 12 non-null object geometry 801 non-null object dtypes: float64(1), object(9) memory usage: 62.7+ KB
demographic_df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 1320 entries, 0 to 1319 Data columns (total 21 columns): Id2 1320 non-null object Percent; RACE - One race 1320 non-null object Percent; RACE - One race - White 1320 non-null object Percent; RACE - One race - Black or African American 1320 non-null object Percent; RACE - One race - Asian 1320 non-null object Percent; RACE - One race - Some other race 1320 non-null object Percent; SEX AND AGE - Total population - Male 1320 non-null object Percent; SEX AND AGE - Total population - Female 1320 non-null object Percent; SEX AND AGE - Under 5 years 1320 non-null object Percent; SEX AND AGE - 5 to 9 years 1320 non-null object Percent; SEX AND AGE - 10 to 14 years 1320 non-null object Percent; SEX AND AGE - 15 to 19 years 1320 non-null object Percent; SEX AND AGE - 20 to 24 years 1320 non-null object Percent; SEX AND AGE - 25 to 34 years 1320 non-null object Percent; SEX AND AGE - 35 to 44 years 1320 non-null object Percent; SEX AND AGE - 45 to 54 years 1320 non-null object Percent; SEX AND AGE - 55 to 59 years 1320 non-null object Percent; SEX AND AGE - 60 to 64 years 1320 non-null object Percent; SEX AND AGE - 65 to 74 years 1320 non-null object Percent; SEX AND AGE - 75 to 84 years 1320 non-null object Percent; SEX AND AGE - 85 years and over 1320 non-null object dtypes: object(21) memory usage: 216.6+ KB
So I'll just coerce the Id2 feature to be strings.
demographic_df['Id2'] = demographic_df['Id2'].astype(str)
demographic_df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 1320 entries, 0 to 1319 Data columns (total 21 columns): Id2 1320 non-null object Percent; RACE - One race 1320 non-null object Percent; RACE - One race - White 1320 non-null object Percent; RACE - One race - Black or African American 1320 non-null object Percent; RACE - One race - Asian 1320 non-null object Percent; RACE - One race - Some other race 1320 non-null object Percent; SEX AND AGE - Total population - Male 1320 non-null object Percent; SEX AND AGE - Total population - Female 1320 non-null object Percent; SEX AND AGE - Under 5 years 1320 non-null object Percent; SEX AND AGE - 5 to 9 years 1320 non-null object Percent; SEX AND AGE - 10 to 14 years 1320 non-null object Percent; SEX AND AGE - 15 to 19 years 1320 non-null object Percent; SEX AND AGE - 20 to 24 years 1320 non-null object Percent; SEX AND AGE - 25 to 34 years 1320 non-null object Percent; SEX AND AGE - 35 to 44 years 1320 non-null object Percent; SEX AND AGE - 45 to 54 years 1320 non-null object Percent; SEX AND AGE - 55 to 59 years 1320 non-null object Percent; SEX AND AGE - 60 to 64 years 1320 non-null object Percent; SEX AND AGE - 65 to 74 years 1320 non-null object Percent; SEX AND AGE - 75 to 84 years 1320 non-null object Percent; SEX AND AGE - 85 years and over 1320 non-null object dtypes: object(21) memory usage: 216.6+ KB
Here's the merge, which does most of the cool work, despite only being one little line.
chicago_demos = pd.merge(left=chicago_census_tracts, right=demographic_df, left_on='geoid10', right_on='Id2')
chicago_demos.head()
statefp10 | countyfp10 | tractce10 | namelsad10 | commarea | geoid10 | commarea_n | name10 | notes | geometry | Id2 | Percent; RACE - One race | Percent; RACE - One race - White | Percent; RACE - One race - Black or African American | Percent; RACE - One race - Asian | Percent; RACE - One race - Some other race | Percent; SEX AND AGE - Total population - Male | Percent; SEX AND AGE - Total population - Female | Percent; SEX AND AGE - Under 5 years | Percent; SEX AND AGE - 5 to 9 years | Percent; SEX AND AGE - 10 to 14 years | Percent; SEX AND AGE - 15 to 19 years | Percent; SEX AND AGE - 20 to 24 years | Percent; SEX AND AGE - 25 to 34 years | Percent; SEX AND AGE - 35 to 44 years | Percent; SEX AND AGE - 45 to 54 years | Percent; SEX AND AGE - 55 to 59 years | Percent; SEX AND AGE - 60 to 64 years | Percent; SEX AND AGE - 65 to 74 years | Percent; SEX AND AGE - 75 to 84 years | Percent; SEX AND AGE - 85 years and over | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 17 | 031 | 842400 | Census Tract 8424 | 44 | 17031842400 | 44.0 | 8424 | None | POLYGON ((-87.62404799998049 41.73021699998396... | 17031842400 | 100.0 | 0.0 | 100.0 | 0.0 | 0.0 | 48.3 | 51.7 | 4.3 | 3.4 | 6.4 | 3.2 | 2.7 | 8.6 | 20.5 | 12.7 | 10.9 | 6.6 | 8.1 | 10.5 | 2.1 |
1 | 17 | 031 | 840300 | Census Tract 8403 | 59 | 17031840300 | 59.0 | 8403 | None | POLYGON ((-87.6860799999848 41.82295600001154,... | 17031840300 | 95.4 | 49.4 | 3.8 | 20.1 | 18.6 | 51.2 | 48.8 | 9.1 | 6.1 | 6.9 | 6.0 | 8.6 | 18.3 | 14.3 | 10.1 | 6.7 | 4.1 | 5.9 | 3.6 | 0.4 |
2 | 17 | 031 | 841100 | Census Tract 8411 | 34 | 17031841100 | 34.0 | 8411 | None | POLYGON ((-87.62934700001183 41.8527970000265,... | 17031841100 | 96.3 | 3.3 | 4.5 | 88.1 | 0.4 | 51.8 | 48.2 | 4.7 | 4.0 | 6.7 | 7.6 | 5.8 | 15.0 | 10.4 | 15.6 | 4.9 | 5.6 | 7.1 | 9.2 | 3.4 |
3 | 17 | 031 | 841200 | Census Tract 8412 | 31 | 17031841200 | 31.0 | 8412 | None | POLYGON ((-87.68813499997718 41.85569099999095... | 17031841200 | 98.2 | 51.8 | 3.9 | 0.4 | 42.0 | 53.1 | 46.9 | 8.1 | 10.3 | 12.3 | 7.6 | 7.5 | 16.9 | 14.1 | 11.5 | 4.8 | 3.3 | 2.9 | 0.5 | 0.3 |
4 | 17 | 031 | 838200 | Census Tract 8382 | 28 | 17031838200 | 28.0 | 8382 | None | POLYGON ((-87.66781999997529 41.8741839999791,... | 17031838200 | 96.6 | 53.6 | 23.3 | 15.2 | 4.4 | 56.5 | 43.5 | 1.4 | 0.6 | 4.9 | 22.4 | 31.5 | 18.8 | 3.1 | 10.6 | 1.4 | 1.5 | 1.5 | 1.6 | 0.5 |
From the printout of types that we saw above, all of the demographic data also had the 'object' (string) type. That's no good, as those should be numbers which can be compared. Pandas is smart about automatically choosing the right data type, so when it chooses the a data type we didn't expect, it's because some of the rows contain bad values. Attempting to coerce to a numeric type (like 'float') returned an error message saying '-' couldn't be converted to a numeric type, so I looked for the rows where demographic features contained '-', and found three rows.
chicago_demos[chicago_demos['Percent; SEX AND AGE - Total population - Female'] == '-']
statefp10 | countyfp10 | tractce10 | namelsad10 | commarea | geoid10 | commarea_n | name10 | notes | geometry | Id2 | Percent; RACE - One race | Percent; RACE - One race - White | Percent; RACE - One race - Black or African American | Percent; RACE - One race - Asian | Percent; RACE - One race - Some other race | Percent; SEX AND AGE - Total population - Male | Percent; SEX AND AGE - Total population - Female | Percent; SEX AND AGE - Under 5 years | Percent; SEX AND AGE - 5 to 9 years | Percent; SEX AND AGE - 10 to 14 years | Percent; SEX AND AGE - 15 to 19 years | Percent; SEX AND AGE - 20 to 24 years | Percent; SEX AND AGE - 25 to 34 years | Percent; SEX AND AGE - 35 to 44 years | Percent; SEX AND AGE - 45 to 54 years | Percent; SEX AND AGE - 55 to 59 years | Percent; SEX AND AGE - 60 to 64 years | Percent; SEX AND AGE - 65 to 74 years | Percent; SEX AND AGE - 75 to 84 years | Percent; SEX AND AGE - 85 years and over | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
85 | 17 | 031 | 980100 | Census Tract 9801 | 56 | 17031980100 | 56.0 | 9801 | Half in CA 64 (Midway Airport) | POLYGON ((-87.73789600001243 41.78578500000872... | 17031980100 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
414 | 17 | 031 | 381700 | Census Tract 3817 | 38 | 17031381700 | 38.0 | 3817 | None | POLYGON ((-87.62798399996935 41.80191199998851... | 17031381700 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
667 | 17 | 031 | 980000 | Census Tract 9800 | 76 | 17031980000 | 76.0 | 9800 | Partially outside City Boundary (O'Hare) | POLYGON ((-87.92062799997296 42.00453199998842... | 17031980000 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
Three census tracts don't have any population data, and that's causing problems. I've plotted these tracts below, and from inspection, I can quickly explain why two of these tracts don't have any population data: they're airports. The upper left tract is O'Hare airport, and the lower left tract is Midway. Per Google, the other tract on the right only includes a strip mall and the Ludwig Van Beethoven Elementary School, so it makes sense that there would be no population. All three of these tracts can be safely zeroed out.
ax = chicago_demos.plot(color='white', edgecolor='black', figsize=(14,14))
chicago_demos[chicago_demos['Id2'].isin(['17031980100', '17031381700', '17031980000'])].plot(ax=ax)
<matplotlib.axes._subplots.AxesSubplot at 0x2310b4f26a0>
chicago_demos[chicago_demos['Id2'].isin(['17031381700'])].plot()
<matplotlib.axes._subplots.AxesSubplot at 0x2310b52eb00>
zero_inds = chicago_demos[chicago_demos['Id2'].isin(['17031980100', '17031381700', '17031980000'])].index.tolist()
for col in chicago_demos.columns:
if "Percent;" in col:
chicago_demos.loc[zero_inds, col] = 0
# Coercing these demographic features to the 'float' type
for col in chicago_demos.columns:
if "Percent;" in col:
chicago_demos[col] = chicago_demos[col].astype(float)
This demographic data is interesting, but if we want to map it out, we need a way to connect these demographic data points to their geographic locations. Fortunately, we can download a shapefile describing the geometries and names of all the census tracts in Chicago from Chicago's Data Portal (click menu, then click Download as a GeoJSON file).
GeoJSON_PATH = os.path.join('data', 'census', 'Boundaries - Census Tracts - 2010.geojson')
with open(GeoJSON_PATH) as geojson:
chi_geojson = json.load(geojson)
chi_map = folium.Map(location=[41.85, -87.6], zoom_start=11)
col = 'Percent; RACE - One race - White'
chi_map.choropleth(geo_data=chi_geojson,
data=chicago_demos,
columns=['Id2', col],
key_on='feature.properties.geoid10',
fill_color='YlGn',
legend_name='White Population: Percentage of Census Tract Pop. (Chicago)',
fill_opacity=0.6,
line_weight=0.3,
highlight=True)
chi_map
def map_census_data(col, title, gdf, cmap='YlGn', figsize=(14,14), scale=0.65, scale_colors=True):
if scale_colors:
vmin = gdf[col].min()
vmax = gdf[col].max()
else:
vmin=0
vmax=100
fig, ax = plt.subplots(figsize=figsize)
base = gdf.plot(color='white', edgecolor='grey', figsize=figsize, ax=ax)
gdf.plot(column=col, cmap=cmap, ax=base, vmin=vmin, vmax=vmax)
_ = ax.axis('off')
_ = ax.set_title('Percentage of Census Tract Pop. (Chicago)\n{}'.format(title),
fontdict={'fontsize': '25', 'fontweight' : '3'})
_ = ax.annotate('Source: American Community Survey, 2015',
xy=(0.1, .1), xycoords='figure fraction',
horizontalalignment='left', verticalalignment='top',
fontsize=10, color='#555555')
sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(vmin=vmin, vmax=vmax))
sm._A = []
cbar = fig.colorbar(sm, shrink=scale)
plt.tight_layout()
map_census_data(col='Percent; RACE - One race - White',
title='White Population',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=False)
map_census_data(col='Percent; RACE - One race - Black or African American',
title='Black or African American Population',
cmap='BuGn',
gdf=chicago_demos,
scale_colors=False)
map_census_data(col='Percent; RACE - One race - Asian',
title='Asian Population',
cmap='OrRd',
gdf=chicago_demos,
scale_colors=False)
map_census_data(col='Percent; RACE - One race - Some other race',
title='Non [White, Black, African American, or Asian] Population',
cmap='Purples',
gdf=chicago_demos,
scale_colors=False)
That deep green tract in the center? Cook County jail is in that tract.
map_census_data(col='Percent; SEX AND AGE - Total population - Male',
title='Male Population',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=False)
map_census_data(col='Percent; SEX AND AGE - Total population - Female',
title='Female Population',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=False)
map_census_data(col='Percent; SEX AND AGE - Under 5 years',
title='Under 5 Years Old',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)
map_census_data(col='Percent; SEX AND AGE - 85 years and over',
title='85 and Older',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)
map_census_data(col='Percent; SEX AND AGE - 5 to 9 years',
title='Ages 5 to 9',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)
map_census_data(col='Percent; SEX AND AGE - 10 to 14 years',
title='Ages 10 to 14',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)
map_census_data(col='Percent; SEX AND AGE - 15 to 19 years',
title='Ages 15 to 19',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)
map_census_data(col='Percent; SEX AND AGE - 20 to 24 years',
title='Ages 20 to 24',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)
The map below is a perfect match with my intuition.
map_census_data(col='Percent; SEX AND AGE - 25 to 34 years',
title='Ages 25 to 34',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)
map_census_data(col='Percent; SEX AND AGE - 35 to 44 years',
title='Ages 35 to 44',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)
map_census_data(col='Percent; SEX AND AGE - 45 to 54 years',
title='Ages 45 to 54',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)
map_census_data(col='Percent; SEX AND AGE - 55 to 59 years',
title='Ages 55 to 59',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)
map_census_data(col='Percent; SEX AND AGE - 60 to 64 years' ,
title='Ages 60 to 64',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)
map_census_data(col='Percent; SEX AND AGE - 65 to 74 years',
title='Ages 65 to 74',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)
map_census_data(col='Percent; SEX AND AGE - 65 to 74 years',
title='Ages 65 to 74',
cmap='YlGn',
gdf=chicago_demos,
scale_colors=True)