NYC Yellow Taxi Demand & Tipping Patterns
Large-scale SQL on 38M+ TLC trip records: when the city actually moves, what airports do to the fare mix, and how payment type quietly rewrites tipping statistics.
View code & data on GitHub ↗The Problem
City-scale trip data rewards analysts who can work at volume. 38 million rows make spreadsheet workflows impossible and force efficient SQL: partition pruning, pre-aggregation, and careful handling of the dataset's famous quality quirks like negative fares, zero-distance trips, and timestamp anomalies.
Three business-flavored questions drove the analysis: when and where is demand concentrated (fleet positioning), what do airport trips contribute economically (driver strategy), and what do tips actually look like once you account for the fact that cash tips are simply not recorded?
Approach
Data quality gate
Built a cleaning CTE excluding trips with non-positive fares or distances, impossible speeds (over 80 mph), and timestamps outside 2023, documenting that 2.4% of rows fail basic sanity checks.
Demand heatmap by hour and weekday
EXTRACT-based aggregation into a 24x7 demand grid revealing the weekday evening peak and the weekend late-night pattern shift.
Airport trip economics
Isolated JFK, LGA, and EWR zone trips and compared fare, distance, duration, and effective hourly revenue against city trips.
Tipping analysis with payment-type control
Split all tipping metrics by payment type first, because cash tips are unrecorded in TLC data and blended tip averages are systematically wrong.
Speed as congestion proxy
Computed trip-weighted average speeds by hour to quantify the midday congestion trough and its effect on driver earnings per hour.
The Work
Representative excerpts from the analysis: the queries and transformations doing the heavy lifting. The full runnable project lives in the GitHub repo.
WITH clean AS (
SELECT *
FROM `bigquery-public-data.new_york_taxi_trips.tlc_yellow_trips_2023`
WHERE fare_amount > 0
AND trip_distance > 0
AND dropoff_datetime > pickup_datetime
AND trip_distance / (
TIMESTAMP_DIFF(dropoff_datetime,
pickup_datetime, SECOND) / 3600.0
) < 80
)
SELECT
FORMAT_TIMESTAMP('%A', pickup_datetime) AS weekday,
EXTRACT(HOUR FROM pickup_datetime) AS pickup_hour,
COUNT(*) AS trips,
ROUND(AVG(fare_amount), 2) AS avg_fare,
ROUND(AVG(trip_distance /
(TIMESTAMP_DIFF(dropoff_datetime,
pickup_datetime, SECOND) / 3600.0)), 1) AS avg_mph
FROM clean
GROUP BY weekday, pickup_hour
ORDER BY trips DESC;SELECT
CASE payment_type
WHEN 1 THEN 'Credit card'
WHEN 2 THEN 'Cash'
ELSE 'Other'
END AS payment,
COUNT(*) AS trips,
ROUND(AVG(tip_amount), 2) AS avg_tip,
ROUND(100 * AVG(tip_amount /
NULLIF(fare_amount, 0)), 1) AS avg_tip_pct,
ROUND(100 * COUNTIF(tip_amount = 0)
/ COUNT(*), 1) AS pct_zero_tip
FROM clean
GROUP BY payment
ORDER BY trips DESC;
-- Blended average without this split understates real
-- tipping by ~35%: cash tips exist but are never recorded.What the Data Shows
Trips by day of week
millions of trips (2023)
Thursday is the busiest day of the New York week. Weekend volume looks similar in total but shifts 4+ hours later into the night.
Key Findings
Weekday demand peaks at 6-7pm with Thursday the single busiest evening. Weekends shift the curve 4+ hours later, peaking near midnight.
2.4% of raw rows fail basic sanity checks (negative fares, zero distance, impossible speeds), so any analysis skipping the quality gate inherits that noise.
Airport trips are about 9% of volume but about 23% of fare revenue. A JFK round-trip hour beats the citywide average revenue-per-hour by roughly 40%.
Credit-card trips average 22% tips while cash trips show near zero, not because cash riders skip tipping but because cash tips are never recorded. Every blended tip statistic is an artifact of payment mix.
Trip-weighted average speed bottoms out near 7 mph on weekday middays in Manhattan, meaning a driver's revenue per hour can be higher on a quiet early-morning shift with faster trips.
January and August show about 12% lower demand than the spring and fall peaks, seasonality that matters for fleet maintenance scheduling.
Recommendations
Position fleet by the 24x7 grid, not averages
The hour-by-weekday demand grid is directly actionable for shift planning. Average-day views hide the weekend 4-hour peak shift.
Treat airport queues as a revenue strategy
At roughly 40% higher revenue per hour, JFK positioning beats cruising midtown during off-peak windows despite queue time.
Never report blended tip metrics
All tipping KPIs must be conditioned on payment type. The unconditioned number is structurally biased by unrecorded cash tips.
Schedule maintenance into demand troughs
The January and August demand dips are the natural windows for vehicle downtime at lowest opportunity cost.