NYC Transportation Analysis
An end-to-end look at NYC's Citi Bike system: cleaning a month of raw trip data, then reading the patterns out of it two ways — when the system gets busy, and where — and writing up what it actually means. Built on January 2024's public trip data (~1.9M rides) and NYC DOT's bike lane network.
01 · The data
The trip data comes from Citi Bike's public System Data feed — January 2024, downloaded directly from Citi Bike's S3 bucket at analysis time, no data committed to the repo. Before anything gets counted, every pipeline in this project (the notebook and both visualizations below) applies the same cleaning rules: drop exact duplicate rides, drop trips that spill outside the claimed month at the file's edges, drop trips with non-positive duration, and drop trips over 24 hours — Citi Bike's own definition of a lost/stolen bike report, not a real ride.
The bike lane network layered into the map below is pulled live from NYC DOT's New York City Bike Routes dataset on NYC Open Data — a separate dataset from Citi Bike's own trip/station data, included to show ridership against the infrastructure it rides on.
CitiBike_Analysis.ipynb — the pandas/matplotlib/seaborn exploratory analysis this page is built on.scripts/ — the pipeline that turns a month of raw trip data into everything on this page.02 · When they ride
Rides broken out by hour of day and day of week — the weekday commute rush shows up as two sharp columns; weekends spread out into one broad midday window instead.
03 · Where they ride
Station-level trip-start density against NYC DOT's actual bike lane network — scrub through the hours to watch the commute rush move across the city, and toggle either layer off to isolate the other.
Manhattan's volume is so much higher than the rest of the city that on the map above, real outer-borough stations can read as empty space next to it — every station shown there is genuine (confirmed against actual NYC borough boundaries, not a rough guess), just comparatively quiet. Below, each borough gets its own map, its own zoom, and its own brightness scale, so its stations are visible on their own terms.
04 · Predicting the rider
The sections above found who/when/where differences at the group level — averages across thousands of trips. Here a model tries something sharper: guess, for one single ride, whether it belongs to a member or a casual rider, using only that trip's duration, distance, timing, bike type, and how busy its start station is.
What predicts it
Model quality (ROC curve)
Random forest confusion matrix
Naive baseline: always guessing "member" already scores accuracy — and identifies zero casual riders. The random forest's accuracy and AUC are shown above alongside that baseline specifically so the headline number can't be mistaken for skill it doesn't have.
05 · The report
Members (people with a subscription) made up 89% of all January 2024 trips, and casual riders (single-ride or day-pass) accounted for the other 11%. Electric bikes outnumbered classic bikes system-wide, 64% to 36%. Trip length is the more interesting number: the average member trip lasted 10.2 minutes, while the average casual trip ran 15.5 minutes, about 52% longer. That tracks with what you'd expect: members using the system for direct, point-to-point commuting, and casual riders treating the ride itself as the point rather than just a way to get somewhere.
The heatmap above makes the weekday commute pattern hard to miss: a sharp double-peak at 8am and 5–6pm, Monday through Friday. Weekends look nothing like that. Ridership spreads into one broad window centered on midday instead of two rush-hour spikes, which fits leisure riding better than commuting. The single busiest hour of the entire month was Wednesday at 5pm, with 33,582 trips starting in that hour alone.
The system spans 2,128 stations, and NYC DOT's bike lane network, 23,807 mapped segments, is built out across all five boroughs. Actual ridership isn't nearly as even. Classifying every station against real NYC borough boundaries (not a rough lat/lng guess) shows Manhattan holding 31% of stations but 66% of all citywide rides. Brooklyn actually has slightly more stations than Manhattan (690 vs. 666) but only 24% of rides. Queens (21% of stations) and the Bronx (15%) trail further behind, at 7% and 3% of rides respectively. Staten Island has real DOT bike lanes but, as of January 2024, zero Citi Bike stations. The borough-by-borough maps below make this concrete: every borough's stations are real, they're just measured on Manhattan's scale on the map above, which makes the quieter ones look emptier than they actually are.
The sections above are all group-level averages. A random forest classifier was trained to answer a sharper question: from a single trip's duration, distance, timing, bike type, and start-station popularity alone, can you tell whether that one ride belongs to a member or a casual rider? A naive model that always guesses "member" already scores 89.0% accuracy while identifying zero casual riders — with a 9-to-1 class split, accuracy alone is a trap. Weighted to actually find the minority class, the forest's raw accuracy drops to 66.7%, but that's the trade working as intended: it correctly identifies 63% of casual riders (ROC-AUC 0.714, clearly above random guessing), against 0% for the naive baseline. Feature importance shows trip speed and duration together account for roughly half the predictive signal — confirming, ride by ride and not just on average, that the "casual trips run ~52% longer" finding above is real signal. Bike type and start-station popularity matter next; hour of day and weekend barely register on their own, even though the heatmap shows a very real group-level pattern.
Put the timing and the geography together and they point at the same thing from two directions: Citi Bike in January 2024 was functioning largely as a commuter-first, Manhattan-centered system. Usage peaks exactly when commutes do, and concentrates exactly where the densest existing transit already is. That reads less like bike share replacing longer cross-borough trips and more like it's filling short last-mile gaps in a system that's already transit-rich. The outer boroughs are real, served, and comparatively quiet. The predictive model above adds a fourth angle that agrees with the first three: how a trip is ridden — fast and short versus slow and long — is a stronger tell of who's on the bike than exactly when or where they got on it.