Calculate CPS labor-force rates in Python

Calculate national participation, unemployment and employment-to-population rates for women aged 25+ with a bachelor’s degree or higher, using prepared monthly microdata and weights.

Measure labor-force participation for a demographic group

Suppose you are writing a national labor-market brief about women aged 25 and older with a bachelor’s degree or higher. You want to know what share are working or looking for work, and what share of that labor force is unemployed. The CPS reference supplies the monthly person records, prepared weights and status labels needed for the calculation, plus a national profile to check the result.

The optional input.csv selects September 2026. The same month appears in the periods list in the Python code below. This is an analysis parameter; no respondent records or survey values are invented.

Download the product samples

Save both files in your working folder. person_months.csv contains the complete September subgroup: all 14,383 civilian women aged 25+ with a bachelor’s degree or higher in this public-use file, with every one of the product’s 28 fields. monthly_profiles.csv contains the matching national profile. This is a complete subgroup excerpt of the paid product, so its weighted estimate can be reproduced; it is not a random handful of rows.

The full $29 edition includes 226,737 civilian person-month records aged 16+ across July, August and September 2026. Its four tables provide person records, household context, 81 national profiles and source-record outcomes. Inspect the complete coverage and fields.

Code example

The code selects the group, sums the prepared composite weights by labor-force status, and calculates three percentages. It checks each result against the supplied profile. The results list remains available in your notebook.

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 decimal import Decimal

# The optional input.csv contains this same selected month.
periods = [{'period': '2026-09'}]

with open('person_months.csv', newline='', encoding='utf-8-sig') as file:
    people = list(csv.DictReader(file))
with open('monthly_profiles.csv', newline='', encoding='utf-8-sig') as file:
    profiles = {(r['period'], r['group_id']): r for r in csv.DictReader(file)}

if len({r['person_month_key'] for r in people}) != len(people):
    raise ValueError('Duplicate person-month records')

results = []
for request in periods:
    month = request['period']
    # A complete subgroup: civilian women 25+, bachelor's degree or higher.
    selected = [r for r in people if r['period'] == month
                and r['PESEX'] == '2' and int(r['PRTAGE']) >= 25
                and 43 <= int(r['PEEDUCA']) <= 46]
    if not selected:
        raise ValueError(f'No subgroup records for {month}')
    totals = {'employed': Decimal(0), 'unemployed': Decimal(0),
              'not_in_labor_force': Decimal(0)}
    for row in selected:
        # This prepared field is already scaled. Do not divide it again.
        totals[row['labor_force_status']] += Decimal(row['labor_force_weight'])
    labor_force = totals['employed'] + totals['unemployed']
    population = sum(totals.values())
    rates = {
        'participation_rate_pct': 100 * labor_force / population,
        'unemployment_rate_pct': 100 * totals['unemployed'] / labor_force,
        'employment_population_ratio_pct': 100 * totals['employed'] / population,
    }
    reference = profiles[(month, 'education_bachelors_plus_sex_2')]
    for field, value in rates.items():
        if abs(value - Decimal(reference[field])) > Decimal('0.000001'):
            raise ValueError(f'{month}: calculated rate differs from supplied profile')
    result = {'period': month, 'respondent_records': len(selected),
              **{field: f'{value:.2f}' for field, value in rates.items()}}
    results.append(result)
    print(f"{month}: {len(selected):,} respondent records; women 25+, bachelor's or higher")
    print(f"Participation: {rates['participation_rate_pct']:.2f}%")
    print(f"Unemployment: {rates['unemployment_rate_pct']:.2f}%")
    print(f"Employment/population: {rates['employment_population_ratio_pct']:.2f}%")

Analysis of the output

2026-09: 14,383 respondent records; women 25+, bachelor's or higher
Participation: 68.62%
Unemployment: 2.22%
Employment/population: 67.09%

The estimated labor-force participation rate is 68.62%: employed and unemployed people together, divided by all civilian women aged 25+ with a bachelor’s degree or higher. The 67.09% employment-to-population ratio uses that same population denominator but counts only employed people in its numerator.

The 2.22% unemployment rate answers a different question: among people in the labor force, what share are unemployed? It excludes people outside the labor force from its denominator. Treating everyone without a job as unemployed would produce the wrong measure.

The 14,383 records are survey observations, not the estimated population. Each prepared labor_force_weight represents a number of people. It equals the original PWCMPWGT integer divided by 10,000; the example uses it directly. The retained PWSSWGT field is a different weight and is not substituted for this labor-force calculation.

These are national, not seasonally adjusted point estimates. Agreement with the supplied profile verifies the calculation, not statistical precision. The product does not supply standard errors or confidence intervals; it does not establish whether a month-to-month difference is statistically significant.

Using the full dataset

Extract the purchased ZIP and replace the two samples with the complete files of the same names. To run the same calculation for all three months, replace periods near the top of the code with:

periods = [{'period': '2026-07'}, {'period': '2026-08'}, {'period': '2026-09'}]

You can also load a CSV containing a period column at that point:

with open('my_months.csv', newline='', encoding='utf-8-sig') as file:
    periods = list(csv.DictReader(file))

To study another group, change the person filter and select its matching group_id from monthly_profiles.csv. The supplied profiles cover five age groups by sex and four education groups by sex; education profiles restrict ages to 25+. These groups overlap, so their populations cannot all be added together. Original category codes, the derived group fields and the full table dictionary support other explicit monthly selections.

household_months.csv joins to person records on household_month_key. It includes noninterview households and does not provide a household analysis weight. source_rows.csv records which original rows became civilian age-16+ observations and which were noninterviews, children, military members or younger civilians. These exclusions are universe decisions, not failed joins.

Keep months separate. The same person can be sampled in multiple months, so adding these monthly records does not count unique people. The identifiers do not supply validated longitudinal linkage. State codes remain in the files, but this guide and the supplied profiles validate national calculations, not local estimates. Retained age masking, top-code indicators and allocation flags matter when interpreting finer groups.

The County Employment & Wage Reference provides workplace job counts and pay from a different source. The ACS County Demographic Profile supplies county estimates over a five-year period. These are useful companion views of the labor market, with different units, periods and survey designs; neither is a person-level join to CPS.

Sources and versions

Source: the Census Bureau’s July, August and September 2026 basic monthly CPS files. This is not the Annual Social and Economic Supplement. ACD retained both original fixed-width and CSV versions, their dictionaries and the public-use weighting documentation. Consult BLS guidance for public-use confidentiality changes and differences from official estimates.

ACD captured the inputs October 19, 2026 UTC and packaged this preparation 2026-10-19. Those are our processing dates, separate from the three source reference months. Server modification dates are retained as acquisition evidence; they are not treated as confirmed original publication dates. This is the first ACD edition of these inputs. The source and preparation record documents coverage and validation.

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