Compare Census tract housing vacancy in Python

Compare vacancy composition in two tracts, keeping housing-unit populations and margins of error visible.

The example and sample data

Two areas can have similar vacancy percentages for very different reasons. For a local housing brief, it helps to distinguish units offered for rent from units reserved for seasonal or occasional use.

Download tract_housing_stock.csv below. It contains two genuine North Carolina tracts, one in Carteret County and one in Wake County, with all 70 fields from the purchased summary file unchanged. The same identifiers appear in the selected list in the Python code below. We selected these tracts to illustrate different vacancy compositions, not as a representative sample. No data were invented.

The full $29 edition covers 85,382 tracts across the 50 states, DC and Puerto Rico. Nine CSVs include housing types, original construction periods, occupancy, vacancy categories, owner/renter structure detail and original source values. Review the full housing-stock download.

Code example

Save the sample in your working directory. This example runs in a notebook cell, IPython or a Python script using the standard library. Keep the eleven-character GEOIDs as text.

Paths are relative to your working folder; use from pathlib import Path; print(Path.cwd()) to check it, or supply full paths.

Python 3.10+ · Jupyter, IPython or a script
import csv
from pathlib import Path

# Two genuine North Carolina tracts, selected to compare vacancy composition.
selected = ["37031970401", "37183053003"]
with Path("tract_housing_stock.csv").open(newline="", encoding="utf-8") as f:
    rows = {r["tract_geoid"]: r for r in csv.DictReader(f) if r["tract_geoid"] in selected}
assert set(rows) == set(selected), "A selected tract is missing"
results = []
for key in selected:
    r = rows[key]
    metrics = ("vacant_pct", "for_rent_among_vacant_pct", "seasonal_among_vacant_pct")
    for field in metrics:
        assert r[field + "_status"] == "calculated", (key, field, r[field + "_status"])
        assert r[field + "_moe_90"] != "", (key, field, "uncertainty unavailable")
    result = {"tract_geoid": key, "tract_name": r["tract_name"], "housing_units": r["housing_units"], "vacant_units": r["vacant_units"]}
    for field in metrics:
        result[field] = r[field]
        result[field + "_moe_90"] = r[field + "_moe_90"]
    results.append(result)
    print(f"{r['tract_name']} ({key})")
    print(f"  {r['housing_units']} housing units; {r['vacant_units']} vacant")
    for field, label in [("vacant_pct", "Vacant, share of all units"),
                         ("for_rent_among_vacant_pct", "For rent, share of vacant units"),
                         ("seasonal_among_vacant_pct", "Seasonal/occasional, share of vacant units")]:
        print(f"  {label}: {float(r[field]):.1f}% "
              f"(90% MOE ±{float(r[field + '_moe_90']):.1f} percentage points)")

Analysis of the output

Census Tract 9704.01; Carteret County; North Carolina (37031970401)
  1201 housing units; 217 vacant
  Vacant, share of all units: 18.1% (90% MOE ±8.4 percentage points)
  For rent, share of vacant units: 4.6% (90% MOE ±6.1 percentage points)
  Seasonal/occasional, share of vacant units: 95.4% (90% MOE ±14.4 percentage points)
Census Tract 530.03; Wake County; North Carolina (37183053003)
  3147 housing units; 574 vacant
  Vacant, share of all units: 18.2% (90% MOE ±7.2 percentage points)
  For rent, share of vacant units: 90.1% (90% MOE ±18.7 percentage points)
  Seasonal/occasional, share of vacant units: 0.0% (90% MOE ±3.3 percentage points)

The two vacant shares are about 18%, but the composition differs. In Carteret County tract 9704.01, Census estimates 217 vacant units: 95.4% are for seasonal, recreational or occasional use, while 4.6% are offered for rent. In Wake County tract 530.03, 90.1% of its estimated 574 vacant units are offered for rent.

The first percentage uses all housing units; the next two use vacant units. The 90.1% figure therefore does not mean that 90.1% of all units in the Wake tract are available to rent. It is also not the conventional rental vacancy rate, which uses a different rental-inventory denominator.

The margins of error matter. The estimated vacant share in Carteret is 18.1% ±8.4 percentage points, compared with 18.2% ±7.2 in Wake. Those estimates do not establish a meaningful difference in their overall vacant shares. Wake’s zero seasonal-use estimate still has a margin of ±3.3 points. These are approximate 90% margins, not exact inventory counts.

This comparison describes the 2020–2024 five-year period. It can support an area profile; it does not identify current listings, housing shortages or abandoned properties. Census’s “other vacant” category has several possible reasons and is not a measure of abandonment.

Using the full dataset

Extract the purchased archive and replace the sample with the full tract_housing_stock.csv. The code runs unchanged; edit selected for your own locations. Join on tract_geoid using compatible 2024 tract geography. The summary supplies one row per tract, with county and state identifiers.

Use vacancy_status.csv for all seven vacancy categories and housing_occupancy.csv for occupied and vacant totals. structure_types.csv describes housing units by structure type, including detached houses, apartments and mobile homes. It counts units, not buildings. construction_periods.csv describes when surviving units were originally built, not their renovation dates or every unit ever constructed.

tenure_structure.csv separates owner-occupied and renter-occupied structure mixes. Select tenure and a category before joining its rows to the summary. Each detail row includes the count, denominator, percentage and uncertainty. source_cells.csv preserves all 56 original estimate/MOE pairs per tract, annotations and variable labels. Stream that large file or load it into a database. Dictionaries, county coverage and source accounting document the rest.

For a fuller area profile, add the tract demographic reference, housing costs reference or commuting reference on the same 2024 GEOIDs and 2020–2024 period. Each product is sold separately. These area-level joins do not establish that the same households experience each condition.

The separate quarterly housing vacancy history supplies national and regional rates with different inventory denominators. Browse the housing collection or geography collection to choose a starting point. Postal address shares cannot allocate tract housing counts or percentages.

Sources and versions

The free original sources are Census’s 2020–2024 ACS five-year Detailed Tables: B25002 (occupancy), B25004 (vacancy status), B25024 (units in structure), B25032 (tenure by units in structure) and B25034 (year built). Census released this edition January 29, 2026. ACD retained the responses, definitions, methodology and geographic inventory on November 13, 2026 UTC.

ACD prepares documented CSVs, explicit denominators and approximate uncertainty while preserving original counts and annotations. Independent checks reconcile every delivered table with retained source responses. Separate source, staging and processing records make the edition reproducible.

The source and preparation record distinguishes the Census edition from our processing. Improvements and documented publisher error corrections to this purchased edition are free; a later source edition is a separate purchase.

Example checked November 13, 2026 against both these samples and the complete purchased files. Source and processing records, sample checksums · Expected result CSV. Independent preparation; no agency endorsement.