Compare resident workforce across ZIP areas in Python

Join fictional service territories to genuine Census workforce and occupation estimates, retaining uncertainty and unmatched ZIPs.

Compare the resident workforce across service territories

A workforce planner or business has a list of postal ZIP codes and wants to understand the kinds of work residents do. This reference adds occupation mix, employment industries and labor-force measures to that area comparison.

input.csv contains four fictional service territories. The same records appear in the territories list in the Python code below. The territory labels and ZIP selections illustrate the join; the Census estimates are genuine.

Save zcta_workforce.csv below in your working directory. It is a smaller version of the paid profile file: complete records for ZCTAs 01001, 10001 and 27513, with all 163 fields unchanged. The optional input CSV is already embedded in the code.

The full $29 edition supplies 33,772 ZCTA profiles, detailed occupation/industry/class-of-worker categories, source counts, margins and coverage in five data tables. It describes residents during 2020–2024, rather than jobs at local employers.

A postal ZIP matched to the same-code Census ZCTA provides approximate area context. ZIP+4 uses only five digits. A match does not validate an address or establish nine-digit precision.

Code example

This uses Python’s standard library and runs in a notebook, IPython or a script. It preserves every input row and prints unemployment, computer/math occupations and healthcare practitioner occupations with approximate 90% margins of error in percentage points.

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
"""Compare resident workforce in fictional service territories. Paste into a notebook or run as a script."""
import csv
import re
from collections import Counter

# These fictional service territories also appear in example_input.csv. They
# illustrate a ZIP join, not real customers or evidence of demand.
territories = [
    {'territory': 'A', 'postal_zip': '01001'},
    {'territory': 'B', 'postal_zip': '27513-1234'},
    {'territory': 'C', 'postal_zip': '10001'},
    {'territory': 'D', 'postal_zip': '00000'},
]


def normalize_zip(value):
    if value is None or isinstance(value, str) and not value.strip():
        return '', '', 'missing_input'
    if not isinstance(value, str):  # Never guess lost leading zeros.
        return '', '', 'invalid_format'
    code = value.strip()
    if re.fullmatch(r'[0-9]{5}', code):
        return code, 'zip5_as_supplied', ''
    if re.fullmatch(r'[0-9]{9}|[0-9]{5}-[0-9]{4}', code):
        return code[:5], 'zip_plus4_to_zip5', ''
    return '', '', 'invalid_format'


def load_profiles(filename):
    profiles = {}
    with open(filename, encoding='utf-8', newline='') as source:
        for row in csv.DictReader(source):
            code = row['zcta_code']
            if not re.fullmatch(r'[0-9]{5}', code) or code in profiles:
                raise ValueError('The reference must have one row per five-digit ZCTA.')
            profiles[code] = row
    return profiles


def enrich_territories(input_rows, profiles):
    output = []
    for order in input_rows:
        code, method, problem = normalize_zip(order['postal_zip'])
        area = profiles.get(code)
        status = problem or ('matched_zcta_code' if area is not None else 'no_zcta_match')
        row = {**order, 'zip5': code, 'normalization_method': method,
               'match_resolution': 'zip5' if code else '', 'match_status': status,
               'matched_zcta_code': code if area is not None else ''}
        for field in [name + suffix for name in ('unemployment_pct', 'computer_mathematical_occupation_pct', 'healthcare_practitioners_occupation_pct')
                      for suffix in ('', '_moe_90', '_status', '_moe_status')]:
            row['area_' + field] = area[field] if area is not None else ''
        output.append(row)
    return output


profiles = load_profiles('zcta_workforce.csv')
results = enrich_territories(territories, profiles)
assert len(results) == len(territories)  # A many-to-one join must preserve input rows.
def display_share(row, metric):
    stem = 'area_' + metric + '_pct'
    if not row[stem]:
        return row[stem + '_status']
    margin = row[stem + '_moe_90']
    uncertainty = f"± {float(margin):.1f} pp" if margin else row[stem + '_moe_status']
    return f"{float(row[stem]):.1f}% {uncertainty}"

for row in results:
    context = row['match_status']
    if context == 'matched_zcta_code':
        context = (f"ZCTA {row['matched_zcta_code']} | Unemployment {display_share(row, 'unemployment')} | "
                   f"computer/math occupations {display_share(row, 'computer_mathematical_occupation')} | "
                   f"healthcare practitioners {display_share(row, 'healthcare_practitioners_occupation')}")
    print(f"{row['territory']} | ZIP {row['postal_zip']} | {context}")
print('Input match coverage:', dict(Counter(row['match_status'] for row in results)))

# Unemployment uses the civilian labor force. Occupation shares use civilian
# employed residents age 16+. MOEs are approximate 90% margins, in percentage
# points. ZIP+4 uses five digits. These are resident estimates, not workplace jobs,
# open positions, available candidates or individual customer characteristics.

Analysis of the output

A | ZIP 01001 | ZCTA 01001 | Unemployment 3.9% ± 1.7 pp | computer/math occupations 2.6% ± 1.1 pp | healthcare practitioners 8.6% ± 2.4 pp
B | ZIP 27513-1234 | ZCTA 27513 | Unemployment 3.5% ± 1.2 pp | computer/math occupations 14.0% ± 2.2 pp | healthcare practitioners 6.0% ± 1.1 pp
C | ZIP 10001 | ZCTA 10001 | Unemployment 5.7% ± 1.3 pp | computer/math occupations 6.7% ± 1.2 pp | healthcare practitioners 3.8% ± 1.3 pp
D | ZIP 00000 | no_zcta_match
Input match coverage: {'matched_zcta_code': 3, 'no_zcta_match': 1}

Territory B retains its ZIP+4 and matches ZCTA 27513 using the first five digits. Its unemployment rate is about 3.5%, with an approximate margin of 1.2 percentage points. Computer and mathematical occupations account for about 14.0% of civilian employed residents, with a margin of 2.2 points; healthcare practitioner and technical occupations account for about 6.0%, with a margin of 1.1 points.

The occupation mix gives the planner a way to compare the work done by residents across territories. Computer/math occupations represent about 2.6% in territory A and 6.7% in territory C. That can guide further research into an area’s workforce, but it does not identify available applicants, qualifications or unmet demand. Residents may work elsewhere.

The denominators matter: unemployment divides unemployed residents by the civilian labor force; the two occupation shares divide employed people in each group by all civilian employed residents age 16+. Do not interpret the unemployment rate as a percentage of the entire population or add it to occupation shares.

Keep margins beside comparisons; this example does not perform a significance test. Sampling uncertainty does not capture postal-ZIP/ZCTA boundary differences. Territory D remains with no_zcta_match because 00000 is absent from the reference. Unavailable measures and zero denominators keep explicit statuses.

Using the full dataset

After purchase, replace the sample with the full zcta_workforce.csv. Replace territories with your own CSV records containing territory and postal_zip, keeping codes as text. Write the results list to a CSV if needed.

The profile includes labor-force participation, five broad occupation groups plus selected specialties, 13 broad employment industries and class-of-worker measures. It combines male and female counts for those shares. Original sex categories and nested groups remain in workforce_categories.csv.

For example, C24010_008E is the male computer/mathematical category and C24010_044E is its female counterpart. The profile’s computer_mathematical_occupation_pct combines both and divides by C24010_001E, all civilian employed residents age 16+. In the detail file, pct uses the table total and pct_of_parent uses the named immediate parent.

Select variables before joining detail rows. Parents contain their children; adding every category double-counts people. Incorporated self-employment is part of private for-profit employment. Occupation and industry are separate tables, not a joint distribution. Repeated customer ZIPs also repeat area totals, so do not sum joined populations as distinct residents.

The ZIP business reference can add employer locations by industry, while the commuting reference adds residents’ travel patterns. These are optional separate purchases with different populations and, for business counts, a different period and postal geography. This guide requires only the workforce reference.

Sources and versions

U.S. Census Bureau, 2020–2024 ACS five-year tables B23025, C24010, C24030 and B24080, released January 29, 2026. Employment status uses residents age 16+; occupation, industry and class of worker use civilian employed residents age 16+. The 2024 ACS reference uses 2020 ZCTA delineations and includes Puerto Rico.

Employment status · Occupation · Industry · Class of worker · Source and preparation record.

Original count margins are retained. Combined counts and shares use documented Census approximations. Processing improvements and genuine publisher error corrections to this purchased edition are included. Future source editions may be sold separately.