Compare college tuition and net price in Python
Add published tuition and income-specific net price to a college shortlist, with source years and reporting populations kept explicit.
Compare costs for a college shortlist
You are comparing Appalachian State, UNC Chapel Hill and NC State. This example adds two useful reference points to that shortlist: published in-state tuition and fees for 2024–25, and average net price for a defined income group in 2023–24. Keeping the years and populations visible lets you use each figure for the question it actually answers.
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, prices or aid values are invented.
college_costs.csv is a small subset of the paid table, retaining every selected measure and column for these universities. institutions.csv supplies their directory and reporting context. Save both files in your working folder. The full $29 reference contains measure rows for 5,871 institutions, a 6,072-institution directory and 81 documented measures covering tuition, attendance costs, net price and financial aid.
Code example
This standard-library example runs in a notebook, IPython or a Python script. It joins the institution directory by unitid, selects the two measures by their exact measure_id, and prints the source reporting flag alongside each value.
Paths are relative to your working folder; use from pathlib import Path; print(Path.cwd()) to check it, or supply full paths.
import csv
from pathlib import Path
# Three real public universities. Replace this list with your own UNITIDs.
selections = [{'unitid': '197869'}, {'unitid': '199120'}, {'unitid': '199193'}]
data_dir = Path('.')
with (data_dir / 'institutions.csv').open(newline='', encoding='utf-8') as f:
institutions = {row['unitid']: row for row in csv.DictReader(f)}
chosen = {row['unitid'] for row in selections}
measures = {}
with (data_dir / 'college_costs.csv').open(newline='', encoding='utf-8') as f:
for row in csv.DictReader(f):
if row['unitid'] in chosen:
measures[row['unitid'], row['measure_id']] = row
def amount(unitid, measure_id):
row = measures.get((unitid, measure_id))
if row is None:
return 'source record unavailable'
if row['value_status'] != 'numeric':
return row['flag_label']
return f"${float(row['value']):,.0f} ({row['flag_label']})"
results = []
for selection in selections:
unit = selection['unitid']
school = institutions[unit]
# These source variables are for public institutions with academic-year prices.
if school['control'] != '1' or school['reporting_method'] != '1':
raise ValueError('Choose the matching source population before comparing this school.')
result = {
'institution': school['institution_name'],
'tuition_fees_2024_25': amount(unit, 'cost1_2024__chg2ay3'),
'net_price_2023_24_income_48001_75000': amount(unit, 'cost2_2024__npis432'),
}
results.append(result)
print(result['institution'])
print(' Published in-state tuition and fees, 2024–25:', result['tuition_fees_2024_25'])
print(' Net price, $48,001–$75,000 family income, 2023–24:', result['net_price_2023_24_income_48001_75000'])
Set data_dir to the folder containing the CSVs. Replace selections with your own identifiers, or read that column from your input CSV. Keep identifiers as text. This example deliberately checks for public institutions with academic-year reporting; private or program-reporting institutions need the corresponding measures from measure_definitions.csv.
Analysis of the output
Appalachian State University
Published in-state tuition and fees, 2024–25: $7,579 (Reported)
Net price, $48,001–$75,000 family income, 2023–24: $15,204 (Reported)
University of North Carolina at Chapel Hill
Published in-state tuition and fees, 2024–25: $8,994 (Reported)
Net price, $48,001–$75,000 family income, 2023–24: $8,538 (Reported)
North Carolina State University at Raleigh
Published in-state tuition and fees, 2024–25: $8,799 (Reported)
Net price, $48,001–$75,000 family income, 2023–24: $13,334 (Reported)
The published tuition-and-fee figures are $7,579 at Appalachian State, $8,994 at UNC Chapel Hill and $8,799 at NC State. They describe the in-state rate for 2024–25, before subtracting aid and without adding books, housing or other living expenses.
The second figure is the average net price for full-time, first-time degree/certificate-seeking undergraduates with family income of $48,001–$75,000 who received Title IV aid in 2023–24. For these public institutions, it uses the lower in-state/in-district tuition rate. UNC Chapel Hill's $8,538 and NC State's $13,334 therefore describe a particular earlier cohort, not offers to the same prospective student.
Net price starts with total attendance costs, including living costs, and subtracts qualifying grants and scholarships. It is not simply tuition minus aid, and loans are not deducted. A net-price figure can exceed tuition because the cost bases differ. These two columns also describe different years; subtracting one from the other would not estimate a student's grant.
All six displayed values have the original Reported flag. Elsewhere in the full table, item flags distinguish reported, imputed and unavailable values. The code leaves unavailable values labeled instead of displaying a zero. The source also contains negative net-price figures, which remain numeric with their original flags; they are aggregate calculation results, not promises of cash payments to students.
Using the full dataset
Extract the purchased ZIP and point data_dir to its CSVs; the code runs unchanged. Use measure_definitions.csv to select a different residency rate, income band, living arrangement or aid category. Each measure documents its original variable, year, population, unit and price basis.
The main table has one unitid × measure_id record per selected source cell. Its 433,092 rows include 284,982 numeric cells and 148,110 blanks. A separate directory preserves institutions that lack a corresponding cost or aid record; absence from a source file is different from a reported zero.
Before comparing institutions, review reporting method and parent/child flags in institutions.csv. Academic-year and largest-program prices can cover different lengths of time. Aid received by all undergraduates differs from aid for first-time full-time students, and recipient groups overlap. Do not sum these groups or average institution-level averages into a student-weighted total.
The other files provide original category labels, an accounting of every source record and a column-by-column description of the prepared selection. Graduate/professional charges, military benefits and earlier embedded years are outside that selection. Complete original dictionaries and a verified example accompany the download.
For programs and awards at these institutions, see IPEDS program completions. For federally aided graduates' earnings and borrowing, see College Scorecard program outcomes. Those products use different populations, reporting units and periods; institution costs do not turn them into a program-specific return-on-investment calculation. The education and careers collection explains how to choose among them.
Sources and versions
The source is NCES IPEDS: COST1_2024, COST2_2024, SFA2324, DRVCOST2024, HD2024 and FLAGS2024. Published costs observe 2024–25; net price and aid observe 2023–24. The COST1/COST2 dictionaries identify a December 2025 provisional release. Directory and reporting-flag files include later updates, so this is an exact mixed-file snapshot captured November 2, 2026, not a single newly published 2026 price edition.
ACD preserves the original files, creates lossless staging tables, then prepares and independently verifies the selected measures. The first ACD release reconciles 25,092 publisher attendance-cost totals with their source components. All four retained layers reproduce offline.
Official downloads are free; the purchase is for the prepared reference and documentation. NCES guidance identifies ED-created material as public domain. No government endorsement is implied. The one-time purchase includes processing improvements and documented publisher error corrections to this source scope. A genuinely new source edition may be sold separately. See the NCES net-price explanation for further definition detail.
Example checked November 2, 2026 against both these samples and the complete purchased files. Source and processing records, sample checksums · Expected result CSV. Independent preparation; no agency endorsement.