Compare HUD rental-assistance programs by county in Python

Compare subsidized units, occupancy and household reports across county program totals.

Compare rental-assistance programs across counties

A housing analyst wants to compare Public Housing and Housing Choice Vouchers in Durham, Mecklenburg and Wake counties, North Carolina. The prepared table supplies program totals, subsidized units, occupied units and household-report counts together, with the row roles needed to select comparable observations.

Download county_assistance.csv below. This is a genuine subset of the purchased table: all 33 source program/subprogram records for these three counties, with all 99 columns unchanged. The county selections appear in the Python code below; no assistance records are invented. The code selects complete individual-program rows rather than adding their overlapping breakdowns.

The full $29 edition includes 23,271 county/program records, 752 state/program records and 17 national records from HUD’s December 31, 2025 snapshot. Seven documented CSVs include program definitions, coverage and quality flags. Inspect the full download.

Code example

Place county_assistance.csv in your working directory. Run the following in a notebook cell, IPython or a script with Python’s standard library. County and program identifiers stay 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

# All source records for these genuine counties are in the free sample.
counties = {'37063': 'Durham, NC', '37119': 'Mecklenburg, NC', '37183': 'Wake, NC'}
programs = {'2': 'Public housing', '3': 'Housing Choice Vouchers'}
with Path('county_assistance.csv').open(newline='', encoding='utf-8') as f:
    selected = {}
    for r in csv.DictReader(f):
        if (r['county_fips'] in counties and r['program'] in programs
                and r['is_program_total'] == '1'):
            key = (r['county_fips'], r['program'])
            if key in selected:
                raise ValueError(f'Duplicate program total: {key}')
            selected[key] = r


missing = {'NA': 'Not applicable', '-1': 'Missing', '-4': 'Suppressed',
           '-5': 'Nonreporting', '': 'Not provided'}
results = []
for county, label in counties.items():
    for program, program_label in programs.items():
        row = selected.get((county, program))
        result = {'county_fips': county, 'county': label, 'program': program,
                  'program_name': program_label}
        for field in ['total_units', 'total_occupied', 'number_reported', 'pct_reported']:
            result[field] = missing.get(row[field], row[field]) if row else 'No source row'
        results.append(result)
        print(f"{label} | {program_label} | units {result['total_units']} | "
              f"occupied {result['total_occupied']} | reports {result['number_reported']} | "
              f"reported % {result['pct_reported']}")

Analysis of the output

Durham, NC | Public housing | units 890 | occupied 634 | reports 407 | reported % 64
Durham, NC | Housing Choice Vouchers | units 3418 | occupied 2578 | reports 2446 | reported % 95
Mecklenburg, NC | Public housing | units No source row | occupied No source row | reports No source row | reported % No source row
Mecklenburg, NC | Housing Choice Vouchers | units 8698 | occupied 5583 | reports 8204 | reported % 100
Wake, NC | Public housing | units 1460 | occupied 1261 | reports 1236 | reported % 98
Wake, NC | Housing Choice Vouchers | units 4851 | occupied 4558 | reports 5040 | reported % 100

Wake’s Housing Choice Vouchers row reports 4,851 subsidized units and 4,558 occupied units. Its Public Housing row reports 1,460 and 1,261 respectively. These fields let you compare the reported scale of the two programs without combining the tenant-based, project-based and Moving to Work breakdowns with their totals.

The household-report columns add a separate measure of reporting coverage. Durham Public Housing has 407 household reports against 634 occupied units, with HUD reporting 64%. Wake’s voucher row has 5,040 reports against 4,558 occupied units, while HUD reports 100%. Reports have effective dates spanning the prior 18 months; they are not the same count as occupied units. The example preserves HUD’s percentage rather than replacing it with a ratio.

Mecklenburg has no Public Housing total row in this extract. The output says “No source row”; it does not invent a zero or establish that the county has no housing assistance. Numeric placeholders in other selections are displayed as missing, suppressed, nonreporting or not applicable, while genuine zeros remain zero.

Using the full dataset

Extract the purchased ZIP and replace the sample county_assistance.csv with the full file. The code runs unchanged. Edit counties and programs for your comparison. Import any county codes from your own CSV as text so leading zeros survive.

For individual programs, keep is_program_total == '1'. To inspect the separate all-HUD summary, select program == '1' and sub_program == 'N/A' directly. Do not add that summary to individual programs. Use program_definitions.csv when choosing a voucher-type or MTW breakdown; these categories overlap, and published subtotals need not exactly reconcile.

The full county table retains 380 records with unknown geography. Their original code remains available but county_fips is blank, so they cannot enter a named-county join. The state and national files are separately published benchmarks, not sums constructed from the county table.

For household characteristics, inspect hh_income, rent_per_month and the demographic fields alongside their definitions and field_coverage.csv. Rent is the reported household contribution including utilities, not asking rent. Average waiting time describes admitted households with dates, not a forecast for a current applicant. Review quality_flags.csv before relying on unusual counts.

The construction and housing markets collection adds LIHTC properties, ACS county housing and HUD rent/income benchmarks. These describe different periods and populations. Links do not establish a property match, an eligibility calculation or an additive count of all assisted housing.

Sources and versions

HUD provides the original Picture of Subsidized Households workbooks and dictionary free. This edition uses the county, state and national 2025 files under the Census 2020 geography heading. The source Quarter is December 31, 2025; household-report effective dates span the prior 18 months. The source page was revised February 17, 2026 and ACD retained it on November 11, 2026 UTC.

ACD adds consistent CSVs, explicit program/geography roles, dictionaries, coverage, review flags and this tested example. The source and preparation record documents dictionary discrepancies and numeric formatting. Processing improvements and publisher error corrections to this purchased edition are included; later source editions may require a new 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.