Check the setup
- Python 3.10 or newer
- A notebook environment such as Jupyter or Google Colab
- A free Census Data API key saved in the CENSUS_API_KEY environment variable
Annual establishment, employment, and payroll counts by industry and county for building local industry-mix and site-selection tools.
From source to product signal
County Business Patterns counts establishments with paid employees by NAICS and geography. Start with one state and the all-industry NAICS code. Employment is a March 12 snapshot, payroll can be suppressed, and CBP excludes most government and self-employed activity.
Install the packages, then run the notebook cell.
python -m pip install pandas requests
import os
import pandas as pd
import requests
response = requests.get(
"https://api.census.gov/data/2023/cbp",
params={
"get": "NAME,ESTAB,EMP,PAYANN,NAICS2017_LABEL",
"for": "county:*",
"in": "state:08",
"NAICS2017": "00",
"key": os.environ["CENSUS_API_KEY"],
},
timeout=30,
)
response.raise_for_status()
rows = response.json()
counties = pd.DataFrame(rows[1:], columns=rows[0])
print(counties.head())Test a useful signal
Test whether CBP can describe which counties hold the most paid employers.
U.S. Census Bureau is a government source. Last verified 2026-08-18. Temporal coverage: 1986-present.