# Reading guide: NYC Subway Crime Rates and Ridership, 1998–2026

The card (`README.md`) is the short account; this guide is the reference beside it: what the terms mean, how every file joins, how to read empty cells and labels, how the numbers were made, and what changed in each version. `QUESTIONS.md` lists the questions the files can explore, `data_dictionary.csv` every column, `sources.csv` every source and `validation_report.md` the checks the build runs.

## A few terms

A few terms used throughout. `law_category` is the NYPD's legal category: felony, misdemeanour or violation. The six major felonies are murder, rape, robbery, felony assault, burglary and grand larceny, leaving out grand larceny of a motor vehicle; the subway-premises records hold no murders. `key_code` (the NYPD's KY_CD) is the broad offence code and `pd_code` (PD_CD) the finer internal code within it. A station complex is the MTA's grouping of stations joined by passageways. Paid rides are the MTA's count of paid entries to the subway; station entries are its taps and swipes at each station, counted by the hour, so they too leave out people who enter without paying; estimated entries add those people back, using the MTA's survey of the unpaid share. Fiscal years run from July to June and are named for the year they end in.

## How the files join

- Join `subway_ridership_monthly.csv` and `city_context_monthly.csv` to `subway_crime_monthly.csv` on `month`: one row each per month, January 2014 to June 2026.
- For `subway_crime_daily.csv` and `subway_crime_by_hour.csv`, first add up the complaint counts by `month`; for `transit_arrests_monthly.csv`, add up `arrests` by `month`. Then join on `month`. Add up counts, never rates or flags.
- `subway_complaints_by_offence_monthly.csv` and `subway_complaints_by_code_monthly.csv` join the monthly table on `month`, many rows to one.
- `fare_evasion_quarterly.csv` joins `subway_ridership_monthly.csv` on `year` and `quarter`, one quarter to three months.
- For one year, `subway_station_crosswalk.csv` joins `subway_stations_annual.csv` on `complex_id`, many places to one complex; across years the join multiplies rows, so never add up the crosswalk's complaints after it. `subway_complaint_records.csv` joins the station table on `complex_id` and `year` (leave out `late_report` rows to match the monthly table).
- To set the subway premises beside `transit_major_felonies_fiscal.csv`, add up the monthly table by `fiscal_year` (its first whole fiscal year is 2015) and join on `fiscal_year`: that makes a separate subway series, it does not reproduce the fiscal file, which counts the whole transit system.
- `subway_stations_reference.csv` has a row per station; collapse it to one row per `complex_id` before attaching it to a complex-level table, or the join repeats rows. Arrests and complaints compare best on `key_code` and `pd_code` (`transit_arrests_monthly.csv` against `subway_complaints_by_code_monthly.csv`), added up by month on each side first; their law categories are written differently (F, M, V against FELONY, MISDEMEANOR, VIOLATION).
- When joining with pandas, pass `validate='one_to_one'` (or `'many_to_one'`) and check the row count afterwards; when grouping the record file, pass `dropna=False` so blank groups are kept.
- `events.csv` joins `sources.csv` on `source_id`.
- Keep every row of the monthly table when joining: an estimate the MTA has not published stays empty.

## Reading the files

- Empty cells mean unavailable or not applicable, never zero. Load counts and rides as nullable integers (pandas `Int64`, integer columns that can hold missing values).
- The two complaint tables by month are sparse: within a covered month (January 2014 to June 2026), an offence with no row had no complaints. Their keys are `month`, `law_category`, `offence`, `complaint_file` and `month`, `key_code`, `offence`, `pd_code`, `complaint_file`. The daily, hourly and station files are full grids: every day, hour or complex-year is present.
- In the count tables, `(null)` in `offence`, `station_name`, `victim_age_group` and similar columns is the label the NYPD's file prints for a blank, kept so that its complaints are counted. In `subway_complaint_records.csv` the same blank is an empty cell, ready to be treated as missing. Labels keep the source's spelling (for example `HARRASSMENT 2`).
- `missing_values.csv` lists every column with empty cells, how many and why: a figure was not published, does not apply, or is blank in the source.
- A month, day or hour is when the offence began (`CMPLNT_FR_DT` and `CMPLNT_FR_TM`), not when it was reported; an arrest's month is the month of the arrest; an hour of entries is the hour people entered.
- Two freshness dates: complaints run to June 2026 (reports to 30 June 2026, retrieved in September and October 2026; `source_snapshot_date`), ridership to September 2026 (the MTA's station-by-station table is whole only to February 2026: from March it lacks some complexes, so its later months are left out). `reporting_window_mature` and `days_since_period_end` say how settled each month is.
- `events.csv` keeps each date at the precision the source gives (YYYY, YYYY-MM or YYYY-MM-DD): read it as text, and do not turn a year or a month into a day.
- Rides and entries are added up from unrounded values, then rounded; rates use the unrounded values and are rounded to four decimals. Annual and fiscal totals can therefore differ by a few rides from the sum of the monthly integers shown.
- `denominator_comparison.csv` and `fare_evasion_measures_quarterly.csv` add up the monthly table's whole numbers of rides and entries, so their sums can differ from the annual file by a few rides; ratios to 2019 are taken from unrounded rates.
- `official_annual_total` repeats on every month of its year in `subway_ridership_monthly.csv`, and `nyc_population` on every month of its year in `city_context_monthly.csv`: take one value per year, never add them up.
- Every finer table counts the same complaints as the monthly table: added up to the month or the year, the daily, hourly, station, victim and report-delay files equal it exactly, and the record file does too once its late reports are left out. The build refuses to write any file unless these checks pass; `validation_report.md` lists them.

## The record file, the classroom file and the notebooks

`subway_complaint_records.csv` holds 187,739 complaint records: the 187,630 complaints in the
monthly table (January 2014 to June 2026) and the 109 late reports, filed in 2026 about earlier
years, two of them about 2005 and 2006 (`late_report` is true; leave them out to reproduce the
monthly table). Each row has the fields the NYPD publishes: when the offence began, ended and was
reported, the offence and its codes, attempted or completed, the place, and the age group and sex
of the victim and of the suspect as recorded. Most columns are categorical, from a handful of
values (law category, borough, day of the week) to hundreds (station, offence code): a good set
for classification (predicting a category), encoding (turning labels into numbers) and clustering
(grouping similar records). Identical rows are separate complaints, so do not remove them as
duplicates.

Its gaps are real. Empty cells correspond to blanks or `(null)` in the NYPD's file and to nothing
else: there is no end date for 16,297 complaints, no suspect age group for 33,830 and no suspect
sex for 31,482. Values the NYPD recorded as UNKNOWN or U are kept as they are, so a missing value
and a value recorded as unknown can be told apart. `missing_values.csv` counts the empty cells in
every file and says why they are empty.

For a first class, `subway_complaints_classroom.csv` is the same complaints made simpler: the
month instead of the day, the borough and transit district instead of the station and its
coordinates, one offence label per offence code across the years, and age codes outside the
NYPD's list marked as invalid; source blanks stay blank. Coarser times and places also make it harder to
pick out any one incident, and nobody should try.

Three notebooks, run and checked with every release, take a class from the first table to a
defensible analysis: `notebook_a_beginner.ipynb` (about an hour: counts against rates, and why a
pooled rate is not an average of rates), `notebook_b_intermediate.ipynb` (a few hours: weekends,
hours of the day, joins and rate ratios with their uncertainty) and `notebook_c_advanced.ipynb`
(a project: ranking stations with intervals and shrinkage, and testing the ranking against the
station matching). Each states its question, the files it needs and the results to expect.

The subway itself is here too. `subway_network_edges.csv` links the 445 station complexes by the
trains that run between them on the current weekday timetable, with minutes and trains an hour,
and `subway_stations_reference.csv` gives every station's complex, coordinates, structure and
accessibility. Together with the station tables they support work on paths, hubs and coverage
as well as on rates.

Two kinds of information are left out on purpose: the complaint number, and the race of victims
and suspects. Leaving them out does not make the records anonymous: precise times, places and
recorded characteristics could be linked to other public information. The files are for
learning, not for identifying anyone or modelling race; for teaching, start from the classroom
file.

## How the numbers were made

The complaint counts are the NYPD's records whose premises is the subway, counted by the month,
day and hour the offence began. The monthly counts by offence were retrieved on 26 September
2026, those by offence code on 11 October, and the finer extracts (day, time, report date, codes,
station, victim group, and every complaint's descriptive fields) on 19 October. The build checks
that each extract, added up by month, equals the earlier files in every cell, so every table
counts the same complaints, and that the record file is the NYPD's extract record for record. The
2026 year-to-date file ends with reports to 30 June 2026; its complaints about earlier years
(late reports) are kept out of the earlier years' counts and shown in their own columns.

Monthly paid rides before March 2020 are estimates. Through December 2019, each calendar year's
official total is spread over its months by an inferred 2019 monthly pattern, rebuilt from the
MTA's comparisons of each 2024 day with its 2019 equivalent, with 29 February 2024 left out.
January and February 2020 together are 2020's official total less the daily counts for March to
December, split between the two months by the same pattern, February's weight multiplied by
29/28 for its leap day. From March 2020 a month's rides are the sum of the MTA's daily figures,
which come within 0.2% of the official yearly totals for 2021 to 2024. Entries are each month's
paid rides divided by one minus the MTA's unpaid share for its quarter, taken to hold evenly
through the quarter. The MTA's station counts are a second, observed series from February 2017:
its hourly ridership tables, summed by month, day and hour of the day (`station_entries` in the
monthly, daily and hourly files). Its station-monthly table holds the same counts by station
complex and agrees with them within 0.1% to February 2026; from March 2026 it lacks some
complexes and has others near zero, so the station files and `station_sum_rides` stop at February
2026. These counts measure entries a little differently from the daily totals (about 1% above them
since 2024) and are kept beside the paid rides, not mixed into them; `denominator_comparison.csv`
shows the headline comparison on each.

Stations are matched by place. The NYPD records a station name and coordinates for every subway
complaint, but its names are older or shared ("125 STREET" is four stations). Each recorded place
is matched to the nearest MTA station within 300 metres whose name shares an identifying word;
failing that, to the station sharing most words within 800 metres (1,500 for two or more words).
Some coordinates sit kilometres from the station named (ROOSEVELT ISLAND placed beside Astoria
Blvd, BOWLING GREEN by Franklin St), so a name that belongs to one complex alone is matched to it
wherever the coordinates are; failing all of these, a place goes to the nearest station. The
station-matching table keeps the distance and the kind of match for every place: 93% of complaints
are matched by name within 300 metres, under 1% by the name alone and under 1% are left uncertain. A station complex is the MTA's grouping of stations joined by
passageways; its name, borough, coordinates, structure, routes and accessibility are the MTA's
current ones, not those of earlier years. Station rates carry a 90% range for a Poisson count;
the range covers chance only, not errors in matching, entries or reporting. The pooled 2023-2025
table also gives a rate shrunk toward the pooled rate of its 417 complexes (an empirical-Bayes,
gamma-Poisson estimate, `sparkylib.stats.shrunk_rates`, whose prior is fitted from the spread of
the complexes' rates) for ranking, and flags whether a complex's expected count at the pooled rate
is at least 10, enough exposure to rank its raw rate on its own.

The fare-evasion comparison adds the NYPD's quarterly subway fare-evasion reports (required by the
City's Administrative Code, section 14-172), from the fourth quarter of 2017: arrests under the
fare-evasion subsection of the theft-of-services law, and the civil summonses returnable to the
Transit Adjudication Bureau. The build checks that each report's transit districts add up to its
citywide total.

Every row of the article's own data file is reproduced from these files before they are
published, every figure this card quotes is checked against them, and the build is checked to
rebuild byte for byte.

## Versions

**1.0** (2026-10-18). First release.

**1.1** (2026-10-19). After an outside review: the licence marked as mixed, with LICENSE.md and the publishers' terms; a Start here section with a tested example; the by-code complaint table; flags for the ride method, the legal changes and incomplete months in the annual and long tables; source file names and locators in sources.csv. Corrected: paid rides are classed as mixed (counted from March 2020); late-report cells for 2026 are empty rather than zero; the rape row of events.csv records signing only. No count, ride or rate changed.

**2.0** (2026-10-19). A wider dataset, built around twenty-five research questions (QUESTIONS.md), with a card written as a story. Added: complaints by day (with that day's rides and weather), by hour, by station complex (with station entries and the station-matching table), by victim group and by reporting delay; every complaint as its own row, for learning and training; Transit arrests; recorded crime across the whole city, on buses, bus rides, population and the shelter census; the MTA's station counts summed by month, an observed check on the modelled months before March 2020; missing_values.csv; and the lockdown, the overnight closure, two fare increases and congestion pricing in events.csv. The code table now holds every offence code. Corrected: theft of services is code 478 under key code 343 everywhere; the card no longer says its complaints rose "while enforcement rose" without the arrests that show the recording changed. No count, ride or rate in the files of version 1.1 changed.

**2.1** (2026-10-22). After an outside review: an observed denominator beside the modelled one, the MTA's station entries, in the monthly table from February 2017 (with rates) and by day and hour from the MTA's hourly ridership, so hourly complaint rates are possible; denominator_comparison.csv shows the headline comparison on three denominators. Station rates gain 90% intervals and the share matched surely, and subway_stations_2023_2025.csv pools three years with a shrunk rate for ranking and a reliability flag. fare_evasion_measures_quarterly.csv sets four records of fare evasion side by side, adding the NYPD's quarterly arrest and summons reports. Added a classroom version of the record file, the subway as a network from the MTA's timetable with its station list, three tested notebooks and a validation report. Renamed: complete to reporting_window_mature (and months_incomplete to months_window_open), with the snapshot date and the days since each month ended; the fiscal file's measure to major_felonies_transit_system. Station matching corrected: a place whose coordinates sit far from the station it names (ROOSEVELT ISLAND beside Astoria Blvd) now goes to the station named, and names with ordinals or only generic words (7TH AVENUE, JUNCTION BLVD.) match by name; the share matched by name within 300 metres rose from 92% to 93%. The MTA's station-monthly table is used to February 2026, its last whole month, so station_sum_rides stops there and monthly station entries come from the hourly tables. The monthly, annual and fiscal counts, paid rides and their rates did not change; station counts moved where the matching did. A second outside review then tightened the release: the hourly file is by day of the week; every analytical file carries the reporting-window, definition or method fields that apply to its rows; the pooled station file ranks against the pooled rate of its complexes, with an exposure flag (expected_at_least_10), shares matched by name for the six major felonies, and full and partial accessibility apart; the station table's agreement with the hourly counts is stated as measured (within 0.1%); and the victim and report-delay files are checked offence by offence.

**2.2** (2026-10-23). The card and the page cut from about 19,000 words to about 3,000 (owner, 22 October): the pitch, how to start, the files, the cautions and the licence stay on them; the terms, every join, the reading notes, the full method and the full version notes move to GUIDE.md, the columns to data_dictionary.csv (and each file's description), and the questions after the first five to QUESTIONS.md. Three pictures from the article: the cover and two charts. No file, column, count or rate changed.

## Credit

    SparkyData (2026). NYC Subway Crime Rates and Ridership, 1998–2026 (version 2.2). SparkyData additions CC BY 4.0; government-source data under publisher terms; code MIT.
    https://sparkydata.dev/data/nyc-subway-crime-and-ridership
