Compare college enrollment and distance education in Python

Add institution size, part-time attendance and distance-education shares to a college shortlist using documented Fall 2024 populations.

Compare the students enrolled at three universities

You are comparing Appalachian State, UNC Chapel Hill and NC State as potential education partners. You want to know the size of each institution and how much of its enrollment is part-time or entirely through distance education. These figures help distinguish institutions that serve different student populations.

The optional input.csv contains the three universities’ genuine IPEDS UNITID identifiers. The same choices appear in the selections list in the Python code below. No institutions or enrollment values are invented.

enrollment.csv and distance_enrollment.csv are subsets of the two paid tables, with all 27 enrollment groups and all five distance-education groups for each university. Every column is unchanged. Save both files in your working folder. The full $29 reference covers 5,842 institutions and adds a directory, definitions, reporting flags and source accounting.

Code example

The code runs in a notebook, IPython or a Python script using the standard library. It selects the all-student population and the corresponding part-time group, checks that the enrollment and distance-education denominators agree, and prints the comparison.

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

folder = Path('.')  # Folder containing the sample or purchased CSV files.
selections = [
    {'unitid': '197869', 'college': 'Appalachian State'},
    {'unitid': '199120', 'college': 'UNC Chapel Hill'},
    {'unitid': '199193', 'college': 'NC State'},
]
wanted = {row['unitid'] for row in selections}

def load_groups(filename):
    with (folder / filename).open(newline='', encoding='utf-8') as f:
        rows = {}
        for row in csv.DictReader(f):
            if row['unitid'] in wanted:
                key = (row['unitid'], row['group_code'])
                if key in rows:
                    raise ValueError(f'Duplicate group: {key}')
                if row['observation_year'] != '2024':
                    raise ValueError('This example requires Fall 2024.')
                rows[key] = row
        return rows

def share(value, total):
    if value == '' or total == '' or int(total) == 0:
        return 'Unavailable'
    return f'{100 * int(value) / int(total):.1f}%'

enrollment = load_groups('enrollment.csv')
distance = load_groups('distance_enrollment.csv')
results = []
for selection in selections:
    unitid = selection['unitid']
    total = enrollment[(unitid, '1')]  # All students, all attendance.
    part_time = enrollment.get((unitid, '41'))  # All part-time students.
    online = distance[(unitid, '1')]  # All students, all attendance.
    if total['total_students'] != online['total_students']:
        raise ValueError('Enrollment and distance denominators differ.')
    result = {
        'college': selection['college'],
        'students': total['total_students'],
        'part_time_share': share(part_time['total_students'] if part_time else '', total['total_students']),
        'exclusively_distance_share': share(online['exclusively_distance_students'], online['total_students']),
    }
    results.append(result)
    print(f"{result['college']}: {int(result['students']):,} students | "
          f"part-time {result['part_time_share']} | exclusively distance {result['exclusively_distance_share']}")

Replace the inline selections with your own institution identifiers or read the unitid column from your CSV. Keep identifiers as text. Change folder if your files are elsewhere. The year check prevents accidentally comparing a different fall edition without reviewing it.

Analysis of the output

Appalachian State: 21,570 students | part-time 11.5% | exclusively distance 11.8%
UNC Chapel Hill: 32,438 students | part-time 8.4% | exclusively distance 5.7%
NC State: 38,464 students | part-time 14.0% | exclusively distance 7.7%

NC State has the largest enrollment of the three, with 38,464 students. Part-time students make up 14.0% of that population, compared with 11.5% at Appalachian State and 8.4% at UNC Chapel Hill. The denominator includes undergraduate and graduate students, not only entering freshmen.

The exclusively-distance shares are 11.8%, 5.7% and 7.7%, respectively. Those students take all their courses through distance education. Students taking a mixture of distance and other courses form a separate category in the download; they are not included in these percentages.

These patterns can inform a comparison of institutional reach and attendance needs. They do not measure teaching quality, demand for a particular major or the residence of all students. The displayed percentages are calculated from original counts and rounded to one decimal place; the supplied CSVs preserve the counts.

These selected totals and attendance/distance counts carry Reported flags. Elsewhere, original imputation flags and blank values remain. The code displays “Unavailable” for a blank count or a zero denominator. An absent part-time group is not silently treated as zero; a missing all-student group stops the example for review.

Using the full dataset

Extract the purchased ZIP and replace the sample files with its enrollment.csv and distance_enrollment.csv. The same code works unchanged. Join institutions.csv on unitid for location, institutional sector, reporting method and parent/child context. The directory includes 6,072 institutions; 230 are absent from the enrollment files, which does not imply zero enrollment.

enrollment_groups.csv identifies the population for each source_table and group_code. Enrollment has 27 possible combinations of attendance, level and entry status. Distance education has five all-attendance groups. Totals and subgroups overlap: choose the desired population before joining or summing rows.

The 113,833 enrollment rows retain 34 count fields, including race/ethnicity, reported men/women and supplemental gender counts. The 21,819 distance rows retain nine counts, including participation and the residence categories of exclusively-distance students. measure_definitions.csv explains all 43 fields and their original variables.

IPEDS allocates students of unknown or another gender into reported men/women counts and supplies supplemental counts as well. Do not add those supplements to the reported totals. The original file also uses an undefined S flag for 6,252 blank supplemental-gender cells. We retain the flag and blank, explicitly note that its meaning is undocumented, and do not label it suppression or imputation.

Use college costs and aid for price context, graduation and retention for entering-cohort outcomes, and program completions for annual awards by field. A matching UNITID identifies an institution; it does not make these populations or periods interchangeable. The education and careers collection explains the available starting points.

Sources and versions

The source is NCES IPEDS: EF2024A, EF2024A_DIST, HD2024 and FLAGS2024. Exact files and all four original dictionaries were retained on November 3, 2026 UTC. The enrollment dictionaries identify provisional data; directory and response files include later updates. Retrieval date is separate from Fall 2024 observations.

Traditional calendars report October 15 or their official fall date. Program/continuous calendars report enrollment during August 1–October 31. This is a fall snapshot, not annual unduplicated enrollment, full-time-equivalent enrollment or a history of growth. Age, student migration, admissions, enrollment by major and retention are outside this product.

All 147,796 original records and 283 source columns are accounted for. Independent verification compares 10,785,347 prepared cells against the original files and checks compatible enrollment totals. Raw sources, lossless staging, preparation and publication have separate identities; offline replay reproduces the exact ZIP.

Government source downloads are free. The purchase covers the prepared reference and documentation. Processing improvements and documented publisher error corrections to purchased scope are included; genuinely new source editions may be separate purchases.

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.