Link Search Menu Expand Document

Making Sense of the Census 🏡 📊

October 25, 2023

These slides were modified from Max Palmer.

Agenda

  • What is the Census? What is the Census Bureau?
  • What is in the Decennial Census and ACS?
  • Where can I find Census Data?
  • Census Geography
  • Race and Ethnicity in the Census
  • Census API Tutorial

What is the Census? What is the Census Bureau?

  • Census Bureau is an “agency” — the part of the federal government responsible for collecting data about the American people and the economy.
  • Decennial Census
  • The American Community Survey (ACS)
  • Other Surveys/Programs
  • Established by the US Constitution

What is in the Decennial Census and ACS?

  • Decennial Census (collected every 10 years)
    • Sex; age; Hispanic origin; race
    • Main Function: provide counts of people for the purpose of congressional apportionment
  • American Community Survey (collected every year)
    • more data than decennial
    • 1 year, 5 year
    • Main Function: measure the changing social and economic characteristics of our population (in terms of education, housing, jobs, and more)
  • Estimations

Where can I find Census Data?

Census Geography

  • Main geography for census is TIGER/Line. Set of shapefiles/geodatabases. Census also produces Cartographic Boundary files.
    • Good for mapping but not detailed geographic analysis.
  • Census geography is organized around the census block
    • Blocks cover entire area of United States
    • Blocks do not overlap
    • Nested within block groups, tracts, counties, and states
    • Legislative districts assembled from blocks
  • Other geographies may not align perfectly with blocks/census geography

Screenshot 2023-10-13 at 12.03.21 PM.png

Screenshot 2023-10-13 at 12.03.29 PM.png

Screenshot 2023-10-13 at 12.03.39 PM.png

Screenshot 2023-10-13 at 12.03.47 PM.png

Screenshot 2023-10-13 at 12.03.56 PM.png

Screenshot 2023-10-13 at 12.04.04 PM.png

Screenshot 2023-10-13 at 12.04.14 PM.png

Screenshot 2023-10-13 at 12.04.24 PM.png

Screenshot 2023-10-13 at 12.04.30 PM.png

Census Geography

  • Blocks -> Block Groups -> Tracts -> Counties -> States
    • These are perfectly nested, no overlaps
    • Blocks identified by GEOID
  • CCDS: 250250101033011
    • 25############# - state (State FIPS Code)
    • ##025########## - county (County FIPS Code; this can be combined with state, 25025)
    • #####010103#### - tract (Note: tract is often named as 101.03)
    • ###########3### - block group
    • ############011 - block (Note: blocks usually include block group, 3011)
  • Data:
    • Decennial data: available by block
    • ACS data: available by block group
  • There are other census geographies available other than the ones we mentioned

Census Geography

  • Blocks are bounded by both visible features and nonvisible boundaries
    • Visible Features: streets, roads, streams, railroad tracks
    • Nonvisible Boundaries: property lines and city, township, school district, and county limits
  • Blocks are not restricted by population, some blocks don’t have any people
  • Block Groups are statistical divisions of census tracts
    • Generally defined to contain 600 and 3,000 people
    • A block group usually covers a contiguous area
    • Each census tract contains at least one block group and they are uniquely numbered within a census tract
  • Census Tracts generally have a population size between 1,200 and 8,000 people with an optimum size of 4,000 people.
    • Covers a contiguous area
    • Spatial size of census tracts varies depending on the denisty of settlement

Race and Ethnicity in the Census

  • The census asks about race and ethnicity separately
  • 2020 census collects data on Hispanic origin and race in 2 separate questions
  • The census follows standards on race and ethnicity set by Office of Management and Budget. The standards identify five minimum categories:
    • White
    • Black or African American
    • American Indian or Alaska Native
    • Asian
    • Native Hawaiian or Other Pacific Islander
    • PLUS a sixth category “Some other Race” for people who don’t identify with any of the OMB race categories.
  • For ethnicity, the OMB standards classify individuals in one of two categories:
    • Hispanic or Latinx or Not Hispanic or Latinx

Working with Census Data Programmatically

  • Census has a great API
  • R packages: tigris (for shapefiles); tidycensus for data
  • Python: CensusData

Using the Census API

Here are all of the publicly available datasets offered by the Census Bureau. We will go over calling data from the Decennial Census.

Reference this documentation to gain a better understanding of the API and how to use it.

import requests
# set variables
year='2020'
dsource='dec' # which survey are we interested in? -> decennial
dname='pl' # a dataset within a survey, pl -> redistricting data
state='25' # state code -> Massachusetts

Below we specify the specific variables (data columns) we want. Here is the complete list of available variables.

  • P2_001N - Total
  • P2_002N - Total: Hispanic or Latino
  • P2_003N - Total: Not Hispanic or Latino
  • P2_004N - Total: Not Hispanic or Latino: Population of One Race
  • P2_005N - Total: Not Hispanic or Latino: Population of One Race: White alone
  • P2_006N - Total: Not Hispanic or Latino: Population of One Race: Black or African American alone
  • P2_007N - Total: Not Hispanic or Latino: Population of One Race: American Indian and Alaska Native alone
  • P2_008N - Total: Not Hispanic or Latino: Population of One Race: Asian alone
  • P2_009N - Total: Not Hispanic or Latino: Population of One Race: Native Hawaiian and Other Pacific Islander alone
  • P2_010N - Total: Not Hispanic or Latino: Population of One Race: Some Other Race Alone
# specify the specific data columns we want
cols = 'NAME,P2_001N,P2_002N,P2_003N,P2_004N,P2_005N,\
        P2_006N,P2_007N,P2_008N,P2_009N,P2_010N'

Call the API to get demographic data for Massachusetts.

base_url = f"https://api.census.gov/data/{year}/{dsource}/{dname}"
census_url = f"{base_url}?get={cols}&for=state:{state}"
census_response = requests.get(census_url)

# check if the response was successful
if census_response.status_code == 200:
    data = census_response.json()
    print(data[0]) # print column names
    print(data[1]) # print data
else: # response was not successful
    print('Error: ' + str(census_response.status_code))
['NAME', 'P2_001N', 'P2_002N', 'P2_003N', 'P2_004N', 'P2_005N', 'P2_006N', 'P2_007N', 'P2_008N', 'P2_009N', 'P2_010N', 'state']
['Massachusetts', '7029917', '887685', '6142232', '5813954', '4748897', '457055', '9387', '504900', '1607', '92108', '25']

Within the Redistricting Data we can get data down to the block level. Not all Census Data Products will allow you to get data down to the block level. You will need to read the documentation to figure out what data is available. Here is more information on finding the right Census Data Product to use.

# get block demographics for block 3011, census block that ccds is in
county = '025'
tract = '010103'
block = '3011'

block_url = f"{base_url}?get={cols}&for=block:{block}&in=tract:{tract}\
              &in=county:{county}&in=state:{state}"
block_response = requests.get(block_url)
block_data = block_response.json()
print(block_data[0]) # print column names
print(block_data[1]) # print data
['NAME', 'P2_001N', 'P2_002N', 'P2_003N', 'P2_004N', 'P2_005N', 'P2_006N', 'P2_007N', 'P2_008N', 'P2_009N', 'P2_010N', 'state', 'county', 'tract', 'block']
['Block 3011, Block Group 3, Census Tract 101.03, Suffolk County, Massachusetts', '71', '9', '62', '61', '41', '6', '0', '10', '0', '4', '25', '025', '010103', '3011']

Other Resources