Compare county house-price growth in Python
Compare genuine annual FHFA county indexes over common years, with missingness and bases explicit.
Compare county house-price growth over the same years
A local-market analyst wants to compare house-price growth in Wake and Mecklenburg counties, North Carolina, with Los Angeles County, California. FHFA’s annual indexes provide a consistent price-change measure, while county FIPS codes make the results usable alongside local population or building-permit data.
Download county_history.csv below. It contains six genuine rows from the purchased table: the 2020 and 2025 observations for those three counties, with all fields unchanged. The county list and endpoint years appear in the Python code below. There are no invented observations.
The full $29 edition contains 106,252 county-year records for 2,795 source counties, separate annual state/national benchmarks, coverage tables and source checks. History extends through 2025, with different starting dates and missing values by county. Inspect the complete download.
Source: FHFA House Price Index® (annual developmental All-Transactions, NSA, nominal). This product uses FHFA data but is neither endorsed nor certified by FHFA.
Code example
Place the CSV in your working directory and run this code in a notebook cell, IPython or a script. It uses Python’s standard library and preserves FIPS codes as text. The calculation divides each county’s ending index by its own starting index; the example stops if either endpoint is missing or the index definition differs.
Paths are relative to your working folder; use from pathlib import Path; print(Path.cwd()) to check it, or supply full paths.
"""Compare nominal county house-price growth over the same annual period."""
import csv
from decimal import Decimal
counties = {"37183": "Wake, NC", "37119": "Mecklenburg, NC", "06037": "Los Angeles, CA"}
start_year, end_year = "2020", "2025"
selected = {}
with open("county_history.csv", newline="", encoding="utf-8") as file:
for row in csv.DictReader(file):
key = row["county_fips"], row["year"]
if key[0] not in counties or key[1] not in {start_year, end_year}:
continue
if key in selected:
raise ValueError(f"Duplicate county-year: {key}")
if (row["index_type"], row["adjustment"], row["price_basis"]) != (
"annual_developmental_all_transactions", "NSA", "nominal"
):
raise ValueError(f"Incompatible index: {key}")
if row["hpi_first_base_status"] != "reported":
raise ValueError(f"Index unavailable for {key}; choose a common reported period")
selected[key] = row
results = []
print(f"Nominal annual house-price change, {start_year} to {end_year}")
for code, name in counties.items():
if any((code, year) not in selected for year in (start_year, end_year)):
raise ValueError(f"Missing endpoint for {name}; check areas.csv and coverage.csv")
start = Decimal(selected[code, start_year]["hpi_first_base"])
end = Decimal(selected[code, end_year]["hpi_first_base"])
growth = (end / start - 1) * 100
results.append(dict(county_fips=code, county=name, start_year=start_year,
end_year=end_year, change_pct=f"{growth:.2f}"))
print(f"{name:<20} {growth:>7.2f}%")
print("Growth is computed within each county; these are not dollar prices or affordability ranks.")
Analysis of the output
Nominal annual house-price change, 2020 to 2025
Wake, NC 57.16%
Mecklenburg, NC 60.20%
Los Angeles, CA 43.28%
Growth is computed within each county; these are not dollar prices or affordability ranks.
Over 2020–2025, the prepared indexes imply approximately 57.16% growth for Wake, 60.20% for Mecklenburg and 43.28% for Los Angeles. These comparisons use the same years and the same index type. They describe cumulative nominal price growth for the properties represented by this index, not changes in median sale prices or inflation-adjusted gains.
Mecklenburg’s larger percentage does not mean its houses cost more than houses in Los Angeles. An index has an arbitrary normalization: the first-base series equals 100 in each county’s first recorded year. Even the alternative 1990 and 2000 bases do not turn index levels into dollar-price comparisons.
The source uses sales prices and refinance appraisals for mortgages bought or guaranteed by Fannie Mae and Freddie Mac. It does not represent every home transaction. These annual developmental estimates are not year-end values, and the example does not explain what caused the differences.
Using the full dataset
Extract the purchased ZIP and replace the sample with the full county_history.csv; the code runs unchanged. Edit counties, start_year and end_year for your analysis. Use areas.csv to check actual starting dates and coverage.csv for annual coverage. Of the 2,795 source county rows in 2025, 2,677 report an index.
The main table preserves 1,057 rows with unavailable first-base indexes. A missing cell and an absent county-year are different: neither is zero growth. Annual changes and the 1990/2000 bases have their own status fields. The published annual change is preserved separately because it can differ slightly from a ratio of rounded index values. The diagnostic file checks that rounding relationship without changing the source.
benchmarks.csv contains separate annual series for the United States, all 50 states and DC. These are not sums or unweighted county averages. Select a geography level and matching index definition deliberately.
The construction and housing markets collection adds county permits and housing context. Review boundary and period compatibility before joining. Connecticut uses planning-region county equivalents here; an older county FIPS table is not an automatic match. ACS estimates and population reference dates also differ from these annual indexes. No geographic allocation or causal relationship is implied.
Sources and versions
The three FHFA annual workbooks are dated March 31, 2026 and were captured November 10, 2026 UTC. Observation coverage ends in 2025. This is a fixed snapshot of revised history, not a collection of each year’s original publication.
FHFA supplies the originals free. ACD adds consistent CSVs, text identifiers, coverage and arithmetic checks, documentation and this verified example. See the source methodology and definitions and source and preparation record.
Processing improvements and documented publisher error corrections to this purchased edition are included. New source editions may be separate purchases.
Example checked November 10, 2026 against both these samples and the complete purchased files. Source and processing records, sample checksums · Expected result CSV. Independent preparation; no agency endorsement.