Compare county GDP and personal income in Python
Compare local output, real GDP growth and income per person using a documented BEA area-year table.
Compare the economies of three counties
You are preparing a county market brief and want to distinguish the size of the local economy, its real output growth and the income residents receive. This example compares Wake and Durham counties in North Carolina with San Francisco, California, using 2024 observations from the Bureau of Economic Analysis.
The optional input.csv contains those three real county/year selections. The same selections appear in the counties list in the Python code below. No GDP or income observations are invented.
Download county_years.csv into your working folder. This is a genuine subset of the paid dataset: all 72 annual records for these three counties, covering 2001–2024 with all 24 product columns unchanged. The full $29 download covers 3,127 BEA county-level area codes across the history, with four companion data tables and documentation. Inspect the complete fields, coverage and files.
Code example
This uses Python’s standard library. Paste it into a notebook cell or IPython, or run it as a script. It selects an exact area and year, converts nominal GDP from thousands of dollars to billions, and attaches the prepared real-growth and per-capita income fields.
Paths are relative to your working folder; use from pathlib import Path; print(Path.cwd()) to check it, or supply full paths.
import csv
from decimal import Decimal
from pathlib import Path
# Selected real counties for an economic-development comparison.
# The optional input.csv contains this same selection.
counties = [
{'bea_area_code': '37183', 'year': '2024'}, # Wake, NC
{'bea_area_code': '37063', 'year': '2024'}, # Durham, NC
{'bea_area_code': '06075', 'year': '2024'}, # San Francisco, CA
]
wanted = {(c['bea_area_code'], c['year']) for c in counties}
reference = {}
with Path('county_years.csv').open(newline='', encoding='utf-8') as file:
for row in csv.DictReader(file):
key = (row['bea_area_code'], row['year'])
if key in wanted:
if key in reference:
raise ValueError(f'Duplicate reference key: {key}')
reference[key] = row
results = []
for county in counties:
key = (county['bea_area_code'], county['year'])
row = reference.get(key)
result = dict(county, area_name='', current_gdp_billions='',
real_gdp_change_percent='', per_capita_income_dollars='',
year_comparison='', status='area_year_not_found')
if row:
result.update(area_name=row['area_name'], status=row['availability'],
year_comparison=row['year_comparison'],
real_gdp_change_percent=row['real_gdp_change_percent'],
per_capita_income_dollars=row['per_capita_income_dollars'])
if row['current_gdp_thousands_dollars']:
result['current_gdp_billions'] = str(
(Decimal(row['current_gdp_thousands_dollars']) / Decimal('1000000'))
.quantize(Decimal('0.01')))
results.append(result)
print(f"{result['area_name'] or county['bea_area_code']} ({county['year']}): "
f"GDP ${result['current_gdp_billions'] or 'n/a'} billion; "
f"real GDP change {result['real_gdp_change_percent'] or 'n/a'}%; "
f"income/person ${result['per_capita_income_dollars'] or 'n/a'}; "
f"{result['status']} / {result['year_comparison'] or 'n/a'}")
Replace counties with your own selections, or load bea_area_code and year from a CSV. Keep area codes as text: San Francisco is 06075. Other areas require the full purchased file.
Analysis of the output
Wake, NC (2024): GDP $128.43 billion; real GDP change 3.3361%; income/person $85573; reported / same_bea_area
Durham, NC (2024): GDP $53.29 billion; real GDP change 5.9341%; income/person $69077; reported / same_bea_area
San Francisco, CA (2024): GDP $268.32 billion; real GDP change 0.8921%; income/person $171497; reported / same_bea_area
Wake’s economy produced about $128.43 billion in 2024, with real GDP 3.3361% above 2023. Durham’s economy is smaller at $53.29 billion, but its real output grew faster, at 5.9341%. San Francisco produced $268.32 billion with 0.8921% real growth. The result gives a market brief both economic scale and growth without confusing rising prices with rising production.
Income per person adds a different view: $85,573 in Wake, $69,077 in Durham and $171,497 in San Francisco. BEA personal income includes income received by or on behalf of residents, including transfers. These averages are not median household income, wages alone or the income of a typical resident. GDP measures production within the county; resident income can originate elsewhere.
The nominal GDP amounts are rounded to two decimals in billions for display. The real growth percentages come from the prepared table’s prior-year calculation; additional decimals do not imply greater source precision. same_bea_area means the calculation compares the same publisher area code. It does not prove constant boundaries or statistical significance.
A selection absent from the reference remains in the result with area_year_not_found. A source value marked unavailable stays blank and keeps its status. Repeated area/year reference keys raise an error rather than producing an ambiguous result.
Combine economic context with business measures
Business applications, employer openings and closures, and workplace employment and wages answer related questions. Median household income and poverty add distributional context. Their concepts and geographic vintages differ; a matching five-digit code alone does not establish a compatible join. Choose business and labor data for your task →
Using the full dataset
Extract the purchased ZIP and replace the sample with its complete county_years.csv. The code runs unchanged against 75,048 area-year records. There are 74,702 area-years with GDP, income and population, plus 346 explicit unavailable rows. In 42 of the reported area-years, BEA marks the quantity index not meaningful while the other five measures remain present.
Use areas.csv to check geography type, original names, source notes and first/last reported year. BEA combines Maui and Kalawao as 15901, and uses 519xx codes for Virginia combinations. These are not individual county FIPS. Connecticut’s eight former counties end in 2023; nine planning regions begin in 2024. Alaska and Broomfield changes also require review. This product supplies no allocation or constant-boundary reconstruction.
Real GDP is in thousands of chained 2017 dollars; nominal GDP and personal income are thousands of current dollars. Do not sum chained-dollar GDP across areas. The prepared annual changes compare immediately adjacent years and withhold calculations for missing baselines or documented boundary-change years. Nominal income growth is not inflation adjusted.
coverage.csv summarizes annual availability; measures.csv provides original BEA line codes and units; source_row_status.csv accounts for both input tables. Original publisher definitions and footnotes, dictionaries, checksums and source/processing records accompany the files.
Sources and versions
Source: BEA CAGDP1 and CAINC1, the February 5, 2026 county release, captured October 31, 2026. The release adds 2024 and revises 2020–2023. The observations, publisher release and ACD processing have separate dates.
County GDP starts in 2001. Personal income is available earlier upstream, but this joined edition uses their shared 2001–2024 window. It contains one revised snapshot, not original-as-published annual vintages.
Your one-time purchase includes ACD processing improvements and documented publisher error corrections to this edition. New observation periods or genuinely new source editions may be sold separately; routine benchmark revisions are not automatically error corrections. There is no membership or automatic refresh. BEA’s original data are free; ACD sells preparation, documentation, validation and delivery. Read the preparation record.
Example checked October 31, 2026 against both these samples and the complete purchased files. Source and processing records, sample checksums · Expected result CSV. Independent preparation; no agency endorsement.