Compare college graduation and retention in Python

Add institution-level persistence and completion measures to a college shortlist, with entering cohorts and denominators kept explicit.

Add graduation and retention to a college shortlist

You are comparing Appalachian State, UNC Chapel Hill and NC State as potential education partners. Alongside their programs and costs, you want to know how often students continue after their first year and finish a degree. This example adds both measures while keeping their different entering cohorts visible.

The optional input.csv contains the three universities' real IPEDS UNITID identifiers. The same selections appear in the selections list in the Python code below. No institutions or outcome values are invented.

college_progress.csv is a subset of the paid table, containing all 42 selected measures for each university with every column unchanged. Save it in your working folder. The full $29 reference supplies measure rows for 5,591 institutions, original graduation count tables, an institution directory, measure definitions and source reporting flags.

Code example

This example runs in a notebook, IPython or a Python script using the standard library. It selects full-time first-year retention and six-year bachelor's completion, checks the entering years, and prints the retention denominator alongside the rates.

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

# A genuine shortlist of North Carolina universities. Replace with your UNITIDs.
selections = [{'unitid': '197869'}, {'unitid': '199120'}, {'unitid': '199193'}]
selected = {row['unitid'] for row in selections}
with open('college_progress.csv', newline='', encoding='utf-8') as f:
    measures = {(row['unitid'], row['measure_id']): row
                for row in csv.DictReader(f) if row['unitid'] in selected}


def value(unitid, measure_id, expected_year):
    row = measures.get((unitid, measure_id))
    if row is None:
        return 'not in source'
    if row['cohort_year'] != expected_year:
        raise ValueError('Unexpected entering cohort; review before comparing')
    if row['value_status'] != 'numeric':
        return 'not available'
    suffix = '%' if measure_id in ('ret_pcf', 'gba6rtt') else ''
    return row['value'] + suffix


results = []
for selection in selections:
    unitid = selection['unitid']
    rows = [row for (unit, _), row in measures.items() if unit == unitid]
    name = rows[0]['institution_name'] if rows else unitid
    results.append({
        'institution': name,
        'retention_2023_entrants': value(unitid, 'ret_pcf', '2023'),
        'retention_adjusted_cohort': value(unitid, 'rrftcta', '2023'),
        'bachelors_within_6yr_2018_entrants': value(unitid, 'gba6rtt', '2018'),
    })
for row in results:
    print(f"{row['institution']}: retained {row['retention_2023_entrants']} "
          f"(2023 entering cohort: {row['retention_adjusted_cohort']}); "
          f"bachelor's within six years {row['bachelors_within_6yr_2018_entrants']} "
          f"(2018 entering cohort)")

Replace the inline selections with your own institution identifiers, or read the unitid column from your CSV. Keep identifiers as text. Change the file path if the downloaded data are in another folder. The cohort assertions are deliberate: a different entering year requires review before comparison.

Analysis of the output

Appalachian State University: retained 84% (2023 entering cohort: 4211); bachelor's within six years 75% (2018 entering cohort)
University of North Carolina at Chapel Hill: retained 97% (2023 entering cohort: 4687); bachelor's within six years 91% (2018 entering cohort)
North Carolina State University at Raleigh: retained 94% (2023 entering cohort: 5536); bachelor's within six years 85% (2018 entering cohort)

For students who entered in fall 2023, the published full-time retention rates are 84% at Appalachian State, 97% at UNC Chapel Hill and 94% at NC State. Their adjusted retention cohorts contain 4,211, 4,687 and 5,536 students. The source uses the original cohort minus permitted exclusions plus qualifying study-abroad inclusions; those underlying counts are available as separate measures.

The bachelor's completion rates—75%, 91% and 85%—follow 2018 entrants for up to six years. At these four-year institutions, that graduation cohort consists of full-time, first-time bachelor's-seeking students. It is not the group used for the 2023 retention rate. Subtracting the two rates would therefore not measure the share who left between their second and sixth years.

These figures can support an institutional comparison, with context about populations and completion windows. They do not isolate teaching quality, predict an individual student's outcome, or describe graduation from a particular major. Differences in the students entering each institution matter. Transfer-in and part-time entrants are outside this graduation cohort; part-time retention has its own measures.

The displayed retention values carry the source's Reported flags. Derived graduation rates have no item flags in their source table; the full download includes original graduation counts and their reporting flags. Blank values elsewhere remain unavailable, not zero. A missing rate and a reported 0% are different results.

Using the full dataset

Extract the purchased ZIP and use its college_progress.csv in place of the sample. The code runs unchanged. Join measure_definitions.csv on measure_id to choose other populations or windows, and institutions.csv on unitid for reporting method, location and source coverage.

The main table contains 223,506 source cells: 122,209 numeric values and 101,297 blanks. Its 42 measures cover overall and subgroup graduation rates, bachelor completion within four/five/six years, transfer-out rates, and full-time/part-time retention counts and rates. Retention data can be unavailable for institutions with short programs.

graduation_counts.csv preserves 51,011 original count records with readable cohort and row-type labels. Filter grtype to the desired denominator or outcome before joining: these rows include overlapping totals, subcohorts, exclusions and completers. short_program_counts.csv supplies 1,535 separate less-than-two-year institution records. Do not sum those different row types into a student total.

Original dictionaries, source category labels, row accounting and field coverage travel with the download. The selected rates exclude Pell/loan subgroup rates, 200%-time graduation and the separate Outcome Measures survey. The short-program count file retains its original aid-group counts, but comparable aid-group counts at other institution levels are outside this product.

Use college costs and aid for price context and program completions for awards by field. Matching UNITIDs identifies an institution; it does not make different cohorts or reporting periods interchangeable. The education and careers collection explains the available starting points.

Sources and versions

The source is NCES IPEDS: GR2024, GR2024_L2, DRVGR2024, EF2024D, HD2024 and FLAGS2024. We retained the exact files and all six original dictionaries on November 3, 2026 UTC. The dictionaries identify provisional files, with later directory and response updates. Capture date is separate from the observation periods.

The GR2024 dictionary introduction contains an outdated 2017/2020 cohort heading. Its category labels, detailed derived-rate definitions and NCES download page agree on 2018/2021; those are the years used here. Some retention-rate descriptions omit study-abroad inclusions, which appear in the adjusted-cohort definitions and arithmetic. We preserve the original text and explain both discrepancies.

All 75,487 original records and 367 original columns are accounted for. Independent verification compares every prepared CSV cell with the original files and checks 23,959 cohort/rate calculations. Raw sources, lossless staging, preparation and publication remain separately identifiable and reproducible.

Government downloads are free; the purchase covers the prepared reference and documentation. Processing improvements and documented publisher error corrections to this purchased source scope are included. Genuinely new source editions may be sold separately.

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