Compare county building permits in Python
Compare annual housing authorizations and the single-family/multifamily mix using Census BPS county data.
Compare housing authorizations across counties
A building-material supplier wants to compare recent residential construction activity in Durham, Mecklenburg and Wake counties, North Carolina. This example compares housing units authorized in 2024 and 2025 and calculates how much of the latest year's activity is in multifamily buildings.
The optional input.csv contains three genuine county identifiers and short market labels. The same selections appear in the selections list in the Python code below. No permit records or estimates are invented.
Download county_years.csv into your working folder. It is a genuine subset of the purchased table: six county-year records for these three counties in 2024–2025, with all 50 fields unchanged. Both estimated and reported-only figures are included. The full $29 edition contains 108,768 county-year records for 1990–2025 and four supporting CSV tables. Inspect the complete product.
Code example
Run this standard-library code in a notebook cell, IPython or a script. It uses estimates including Census imputation, requires both years for each county, and checks the source-quality flag before calculating growth. Keep county identifiers as text.
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, ROUND_HALF_UP
# These are real county identifiers selected for a local-market comparison.
selections = [
{"county_fips": "37063", "market": "Durham"},
{"county_fips": "37119", "market": "Mecklenburg"},
{"county_fips": "37183", "market": "Wake"},
]
wanted = {item["county_fips"] for item in selections}
county_years = {}
with open("county_years.csv", newline="", encoding="utf-8") as source:
for row in csv.DictReader(source):
if row["county_fips"] in wanted and row["year"] in {"2024", "2025"}:
key = row["county_fips"], row["year"]
if key in county_years:
raise ValueError(f"Duplicate county-year: {key}")
county_years[key] = row
results = []
for item in selections:
code = item["county_fips"]
if any((code, year) not in county_years for year in ("2024", "2025")):
raise ValueError(f"Both years are required for {code}; absence is not zero.")
before, after = (county_years[code, year] for year in ("2024", "2025"))
if any(row["quality_status"] != "checks_passed" for row in (before, after)):
raise ValueError(f"Review source_issues.csv before comparing {code}.")
old_units, units = int(before["estimate_total_units"]), int(after["estimate_total_units"])
change = (Decimal(100) * (units - old_units) / old_units).quantize(
Decimal(".1"), rounding=ROUND_HALF_UP
) if old_units else None
result = {
"county_fips": code,
"market": item["market"],
"units_2024": old_units,
"units_2025": units,
"change_pct": str(change) if change is not None else "undefined",
"multifamily_share_2025_pct": after["estimate_multifamily_share_pct"],
}
results.append(result)
change_text = f"{change:+.1f}%" if change is not None else "undefined"
print(f"{item['market']}: {old_units:,} → {units:,} authorized units "
f"({change_text}); multifamily share {after['estimate_multifamily_share_pct']}%")
Analysis of the output
Durham: 2,905 → 4,772 authorized units (+64.3%); multifamily share 41.53%
Mecklenburg: 11,969 → 7,496 authorized units (-37.4%); multifamily share 50.01%
Wake: 15,248 → 13,806 authorized units (-9.5%); multifamily share 39.21%
Durham's authorized units increased from 2,905 to 4,772, while Mecklenburg and Wake declined. Multifamily buildings accounted for 41.53% of Durham's 2025 authorized units, compared with 50.01% in Mecklenburg and 39.21% in Wake. A supplier can use this comparison to identify markets for closer research and distinguish single-family from multifamily activity.
The figures count housing units authorized, not completed homes, starts or individual permit documents. Multifamily means structures containing two or more units; the denominator is total authorized units, not buildings. One large apartment project can materially change a county's annual total. These figures do not establish subsequent construction, sales, profitability or statistical significance.
The estimate and reported-only columns overlap; do not add them. Their difference is not a survey response rate. The construction collection adds national spending and local housing context, with the different measures and geographic scopes explained.
Using the full dataset
Extract the purchased ZIP and replace the sample with its complete county_years.csv. The code runs unchanged. Replace the county selections and the two year strings to analyze other markets and periods. Each county_fips + year key is unique.
The full table retains buildings, housing units and nominal permit valuation for 1-unit, 2-unit, 3–4-unit and 5+-unit structures, separately for estimates including imputation and reported-only figures. Valuation is not actual spending or an inflation-adjusted measure. Annual totals and multifamily shares are explicitly derived from the four structure types.
coverage.csv shows each year's observed coverage and permit-office universe. Missing county-years are absent, not zero. Source names and codes remain year-specific; Connecticut changes from eight counties to nine planning regions in 2023. Review boundary and permit-coverage changes before interpreting long trends or joining other county products.
other_areas.csv retains 175 noncounty source records separately. Ten extra duplicate-label records are audited in duplicate_aliases.csv and counted only once. Twelve county-year records have published consistency exceptions, identified in source_issues.csv; original values remain unchanged. The example stops on a flagged record so you can review it before using it.
Sources and versions
Source: the Census Building Permits Survey annual county files, 1990–2025, retained November 8, 2026 UTC. Final 2025 annual statistics were released May 14, 2026. Earlier files contain the publisher revisions available at capture, not their original release vintages.
The definitions and methodology explain private residential scope, permit-office coverage and imputation. These are published county totals, not a directory of addresses or contractors.
Census provides the sources free. ACD sells preparation, checks, documentation and delivery. Processing improvements and publisher error corrections to the purchased edition are included; routine new source editions and reporting years may be separate purchases. Read the source and preparation record.
Example checked November 8, 2026 against both these samples and the complete purchased files. Source and processing records, sample checksums · Expected result CSV. Independent preparation; no agency endorsement.