Compare county housing-cost burdens by income in Python

Compare renter households and severe housing-cost burdens within a HUD income group, keeping margins of error and denominators explicit.

Compare rent burdens within the same income group

A housing analyst is comparing Durham, Mecklenburg and Wake counties in North Carolina. The question is how many renter households in HUD’s lowest income group spend more than half their income on housing. The prepared table brings together the published group total, severe-burden count, margin of error and cases whose burden cannot be computed.

Download county_income_burden.csv below. It is a genuine subset of the purchased file: all 30 owner/renter and income-group rows for these three counties, with all 24 columns unchanged. The county selections are in the Python code below; no household records are invented. These are aggregate estimates, not individual household records.

The full $29 edition covers 3,222 county equivalents and 32,220 county/tenure/income groups, with seven CSV tables. It uses HUD CHAS 2018–2022 five-year estimates, released December 2025. Inspect the full download.

Code example

Save county_income_burden.csv in your working directory. Run this code in a notebook cell, IPython or a Python script; it uses only the standard library. The selection le30 means household income at or below 30% of HUD Area Median Family Income (HAMFI) for the source period.

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

# Use the genuine sample CSV here, or the same file from the purchased ZIP.
data_file = Path('county_income_burden.csv')
counties = ['37063', '37119', '37183']  # Durham, Mecklenburg and Wake, NC
results = []
with data_file.open(encoding='utf-8', newline='') as stream:
    for row in csv.DictReader(stream):
        if (row['county_fips'] in counties and row['tenure'] == 'renter'
                and row['income_band'] == 'le30'):
            households = int(row['households'])
            severe = int(row['burden_gt50'])
            share = 100 * severe / households if households else None
            results.append({
                'county_fips': row['county_fips'],
                'county_name': row['county_name'],
                'income_band': row['income_band'],
                'households': households,
                'severe_burden_households': severe,
                'severe_burden_moe': int(row['burden_gt50_moe']),
                'burden_not_computed': int(row['burden_not_computed']),
                'severe_burden_pct_of_all_group_households':
                    '' if share is None else f'{share:.1f}',
            })

if {r['county_fips'] for r in results} != set(counties):
    raise ValueError('A selected county/income group is absent from this file')
for row in results:
    print(f"{row['county_name']}: {row['severe_burden_households']:,} of "
          f"{row['households']:,} low-income renter households have housing costs "
          f"above 50% of income ({row['severe_burden_pct_of_all_group_households']}%); "
          f"published count MOE ±{row['severe_burden_moe']:,}; "
          f"{row['burden_not_computed']:,} have cost burden not computed.")

Analysis of the output

Durham County, North Carolina: 7,235 of 11,915 low-income renter households have housing costs above 50% of income (60.7%); published count MOE ±777; 1,405 have cost burden not computed.
Mecklenburg County, North Carolina: 22,560 of 32,435 low-income renter households have housing costs above 50% of income (69.6%); published count MOE ±1,237; 4,080 have cost burden not computed.
Wake County, North Carolina: 21,865 of 30,770 low-income renter households have housing costs above 50% of income (71.1%); published count MOE ±1,309; 2,205 have cost burden not computed.

Wake has an estimated 21,865 severely cost-burdened renter households in this income group, out of a published group total of 30,770. The resulting descriptive share is 71.1%. Mecklenburg’s corresponding figures are 22,560 of 32,435 (69.6%); Durham’s are 7,235 of 11,915 (60.7%). These give the analyst both a measure of scale and a within-group comparison.

The denominator is the entire published income/tenure group, including households whose cost burden is not computed because their income is zero or negative. Wake has 2,205 such cases. They are kept separate from households with a reported zero burden; excluding them would answer a different question.

The reported margins of error belong to the severe-burden counts: Wake’s is ±1,309 households. It is not a percentage-point margin for the calculated 71.1%. The example does not calculate uncertainty for the ratios or establish that the counties differ statistically.

HUD rounds household counts, so the four burden categories can differ from their published subtotal. Use households as supplied rather than reconstructing it. The difference is visible in burden_partition_difference and the full rounding_checks.csv.

Using the full dataset

Extract the purchased ZIP and replace the sample CSV with its full counterpart. The code runs unchanged. Change the counties list, tenure selection or income_band to compare other groups. Import county identifiers as text to preserve leading zeros; county, tenure and income band together identify one row.

For kitchen and plumbing conditions within burden groups, use cost_burden_detail.csv. It retains every Table 8 estimate and margin of error with readable categories. Select the desired row_role and categories before aggregating: totals and subtotals overlap the detail rows.

housing_problem_severity.csv provides a different view: an ordered classification from Table 3. Households lacking kitchen/plumbing facilities are assigned first, then overcrowded households, then the cost-burden categories. Later categories exclude the earlier problems. Consequently, Table 3’s severe-cost-burden category is not overall severe-burden prevalence; use Table 8 or the main table for the comparison above.

County codes include nine Connecticut planning regions and 78 Puerto Rico municipios. Check geographic vintages before adding other county data. The construction and housing collection connects this reference to ACS affordability, LIHTC properties and HUD assistance. Their periods and populations differ; subtracting assistance counts from CHAS need estimates does not establish a current housing-unit shortage.

Sources and versions

HUD supplies the original CHAS county tables free, with an official dictionary and rounding guidance. This product prepares complete Tables 3 and 8 from the 2018–2022 edition, released December 23, 2025 and captured November 11, 2026 UTC. It is a five-year estimate, not current housing-program eligibility data.

ACD adds labeled CSVs, published-subtotal selections, source-variable references, rounding checks and this verified example. The release record separates the source period from our processing. Improvements and publisher error corrections to this purchased edition are included; later source editions may require another purchase.

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