Compare county health indicators and confidence intervals in Python

Add modeled diabetes prevalence and screening estimates to a county comparison using CDC PLACES, a genuine product sample and copyable Python.

Compare health indicators across counties

A county healthcare brief needs more than spending and population counts. CDC PLACES adds estimates of conditions such as diabetes, preventive screening and health-related social needs. This example compares diabetes prevalence and colorectal cancer screening in Wake and Durham counties, North Carolina, and Jefferson County, Kentucky.

The optional input.csv contains those three real county codes and display labels. The same selections appear in the counties list in the Python code below. These are example research selections; no patient records or health estimates have been invented.

Download county_measures.csv into your working folder. It is a sample of the file included in the paid product: all 40 measure rows for each of these three counties, with the same fields and values. The code selects two measures from that sample. The full download covers 3,144 counties and includes definitions, national benchmarks and coverage summaries.

Each row pairs the crude and age-adjusted estimate with its 95% confidence interval. We use the age-adjusted fields here to compare places while accounting for differences in age composition. Keep the measure’s survey year and eligible population with the result.

Code example

Run this in a notebook cell, IPython or a Python script. It needs only the standard library. County FIPS codes remain strings so leading zeros survive.

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

data_dir = Path('.')  # Folder containing county_measures.csv
counties = [
    {'county_fips': '37183', 'label': 'Wake, NC'},
    {'county_fips': '37063', 'label': 'Durham, NC'},
    {'county_fips': '21111', 'label': 'Jefferson, KY'},
]
measures = ['DIABETES', 'COLON_SCREEN']

with (data_dir / 'county_measures.csv').open(newline='', encoding='utf-8') as f:
    reference = {(r['county_fips'], r['measure_id']): r for r in csv.DictReader(f)}

results = []
for county in counties:
    for measure in measures:
        row = reference.get((county['county_fips'], measure))
        status = row['estimate_status'] if row else 'outside_reference'
        result = {
            'county': county['label'], 'measure': measure,
            'brfss_year': row['brfss_year'] if row else '',
            'age_adjusted_pct': row['age_adjusted_pct'] if row else '',
            'lower_95': row['age_adjusted_lower_95'] if row else '',
            'upper_95': row['age_adjusted_upper_95'] if row else '',
            'status': status,
        }
        results.append(result)
        estimate = (f"{result['age_adjusted_pct']}% (95% CI {result['lower_95']}–{result['upper_95']})"
                    if status == 'reported' else status)
        print(f"{result['county']:14} | {measure:12} | {result['brfss_year']} | {estimate}")

To use your own county list, replace counties with records containing county_fips and label. For a CSV with those fields, read it with csv.DictReader. Change measures to the CDC measure identifiers you want; the complete download’s measure_definitions.csv lists all 40.

Analysis of the output

Wake, NC       | DIABETES     | 2023 | 9.0% (95% CI 7.7–10.4)
Wake, NC       | COLON_SCREEN | 2022 | 64.0% (95% CI 59.6–68.4)
Durham, NC     | DIABETES     | 2023 | 10.4% (95% CI 9.0–12.1)
Durham, NC     | COLON_SCREEN | 2022 | 62.6% (95% CI 57.6–67.4)
Jefferson, KY  | DIABETES     | 2023 | not_in_source
Jefferson, KY  | COLON_SCREEN | 2022 | 63.0% (95% CI 58.4–67.3)

Wake’s age-adjusted diabetes estimate is 9.0%, with a 95% confidence interval of 7.7–10.4%. Durham’s is 10.4%, with an interval of 9.0–12.1%. These modeled estimates add local health context to a county brief. The intervals show uncertainty; the printed difference alone does not establish a statistically significant difference.

Colorectal screening refers to adults aged 45–75, while the diabetes measure refers to adults aged 18 or older. Their survey years differ too: screening uses 2022 BRFSS and diabetes uses 2023. They can appear in the same report with those labels, but they are not interchangeable percentages or observations from a common 2025 survey.

Jefferson has a screening estimate but no diabetes estimate in this edition. CDC’s 2023-based measures exclude Kentucky and Pennsylvania. The row therefore prints not_in_source; it does not mean that nobody has diabetes. A separate suppressed status applies when CDC supplies a row but withholds its estimate. A code absent entirely from your reference file prints outside_reference, prompting a check of the code, geography and file coverage.

For context about the actual population composition, the file also retains crude estimates. Do not multiply age-adjusted percentages by county population to estimate patient counts. Some measures have conditional or age-specific populations, so the county’s total adult population is not a universal denominator.

Using the full dataset

After purchase, extract the ZIP and point data_dir to that folder. The example runs unchanged with the complete county_measures.csv. Its 125,760 rows include 114,576 reported county/measure pairs, 33 suppressed pairs and 11,151 combinations absent from CDC’s source. Filter on estimate_status when selecting numeric observations.

The six CSV tables include the paired estimates, county context, definitions for every measure, separate national benchmarks, state/measure availability and source-row accounting. National social-needs benchmarks retain CDC’s limitation to 39 states and DC. Metadata, field dictionaries, validation results and retained source identities accompany the data.

Use this for descriptive health context and needs assessment. CDC does not recommend PLACES for overall health rankings, local trend analysis or evaluating local policies and interventions. Check county boundaries and observation periods before adding Medicare spending or insurance estimates. The county healthcare selection guide explains how those products fit together.

Sources and versions

This example uses CDC’s PLACES county 2025 release. The portal data update is December 4, 2025. Thirty-five measures use 2023 BRFSS and five use 2022 BRFSS; Census 2023 populations and ACS inputs support the models. ACD captured and prepared this source edition on October 22, 2026 UTC. It is the first ACD edition, not a release-to-release change analysis.

Read CDC’s release notes, modeling methodology, measure definitions and interpretation guidance. The original government data are free; ACD provides prepared tables, documented joins, coverage checks and reproducible processing.

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