Public dataset · Government, society and transport
NYC Taxi Trips in BigQuery
The new_york_taxi_trips dataset has NYC yellow taxi trips from 2011, green taxi trips from 2014 and for-hire vehicle trips for 2015 to 2017, one table per type and year, plus taxi zone polygons. Yellow tables run up to 47 GiB each, and SELECT * over all years reads 274 GiB, so query one year and name your columns.
bigquery-public-data.new_york_taxi_trips holds trip records from the New York City Taxi and Limousine Commission (TLC), one table per vehicle type and year. The dataset description gives 2023-03-21 as the last data update. The yellow and green tables for 2023 were created then but are empty, so the data effectively ends in 2022.
tlc_yellow_trips_YYYY (2011 to 2022) and tlc_green_trips_YYYY (2014 to 2022) have one row per trip with pickup and dropoff time, distance, passenger count, rate code, payment type and every fare component (fare_amount, tip_amount, tolls_amount, total_amount). Places are identified by pickup_location_id and dropoff_location_id, which join to zone_id in taxi_zone_geom, a table of 263 zones with borough names and GEOGRAPHY polygons. tlc_fhv_trips_2015 to 2017 cover for-hire vehicles with the pickup time or date, dispatching base and pickup zone (the 2017 table adds dropoff date and zone), but no fares.
payment_type is the TLC code stored as a string: 1 is credit card and 2 is cash. None of the tables is partitioned or clustered; the split by year is the only built-in way to read less.
Tables and sizes
| Table | Rows | Size | Full scan | Layout |
|---|---|---|---|---|
tlc_yellow_trips_2014Yellow taxi trips, 2014. | 275,921,951 | 47.1 GiB | $0.29 | None |
tlc_yellow_trips_2012Yellow taxi trips, 2012. | 256,415,130 | 44.9 GiB | $0.27 | None |
tlc_yellow_trips_2013Yellow taxi trips, 2013. | 185,787,446 | 32.5 GiB | $0.20 | None |
tlc_yellow_trips_2011Yellow taxi trips, 2011. | 176,887,248 | 31.0 GiB | $0.19 | None |
tlc_yellow_trips_2015Yellow taxi trips, 2015. | 146,039,220 | 25.8 GiB | $0.16 | None |
tlc_yellow_trips_2016Yellow taxi trips, 2016. | 131,131,794 | 23.2 GiB | $0.14 | None |
tlc_yellow_trips_2017Yellow taxi trips, 2017. | 113,500,316 | 20.0 GiB | $0.12 | None |
tlc_yellow_trips_2018Yellow taxi trips, 2018. | 102,871,376 | 18.3 GiB | $0.11 | None |
tlc_fhv_trips_2017For-hire vehicle trips, 2017: base, dates and zones, no fares. | 192,092,698 | 15.6 GiB | $0.10 | None |
tlc_yellow_trips_2019Yellow taxi trips, 2019. | 84,598,433 | 15.1 GiB | $0.09 | None |
tlc_yellow_trips_2022Yellow taxi trips, 2022. | 36,256,539 | 7.0 GiB | $0.04 | None |
tlc_fhv_trips_2016For-hire vehicle trips, 2016: base, dates and zones, no fares. | 133,285,141 | 6.3 GiB | $0.04 | None |
tlc_yellow_trips_2021Yellow taxi trips, 2021. | 30,904,297 | 5.9 GiB | $0.04 | None |
tlc_yellow_trips_2020Yellow taxi trips, 2020. | 24,649,081 | 4.4 GiB | $0.03 | None |
tlc_green_trips_2015Green taxi trips, 2015. | 19,233,754 | 3.5 GiB | $0.02 | None |
tlc_fhv_trips_2015For-hire vehicle trips, 2015: base, dates and zones, no fares. | 63,867,609 | 3.1 GiB | $0.02 | None |
tlc_green_trips_2016Green taxi trips, 2016. | 16,385,530 | 3.0 GiB | $0.02 | None |
tlc_green_trips_2014Green taxi trips, 2014. | 15,836,998 | 2.6 GiB | $0.02 | None |
tlc_green_trips_2017Green taxi trips, 2017. | 11,737,048 | 2.1 GiB | $0.01 | None |
tlc_green_trips_2018Green taxi trips, 2018. | 8,899,707 | 1.6 GiB | under $0.01 | None |
tlc_green_trips_2019Green taxi trips, 2019. | 6,300,974 | 1.1 GiB | under $0.01 | None |
tlc_green_trips_2020Green taxi trips, 2020. | 1,734,165 | 314 MiB | under $0.01 | None |
tlc_green_trips_2021Green taxi trips, 2021. | 1,068,744 | 192 MiB | under $0.01 | None |
tlc_green_trips_2022Green taxi trips, 2022. | 767,953 | 143 MiB | under $0.01 | None |
taxi_zone_geom263 taxi zones with borough and GEOGRAPHY polygon. | 263 | 2.3 MiB | under $0.01 | None |
tlc_green_trips_2023Empty. | 0 | 0 B | under $0.01 | None |
tlc_yellow_trips_2023Empty. | 0 | 0 B | under $0.01 | None |
Example queries
Trips, average fare and distance per month in 2022
One year's table and three columns.
SELECT
DATE_TRUNC(DATE(pickup_datetime), MONTH) AS month,
COUNT(*) AS trips,
ROUND(AVG(fare_amount), 2) AS avg_fare,
ROUND(AVG(trip_distance), 2) AS avg_miles
FROM `bigquery-public-data.new_york_taxi_trips.tlc_yellow_trips_2022`
GROUP BY month
ORDER BY month;Trips over $500 across all yellow-taxi years with SELECT * (expensive)
The tlc_yellow_trips_* wildcard reads every yearly table, and SELECT * reads every column of each.
SELECT *
FROM `bigquery-public-data.new_york_taxi_trips.tlc_yellow_trips_*`
WHERE total_amount > 500;The same trips counted per year, reading one column
Same filter, same tables, but only total_amount is read: about 12 times fewer bytes. Add WHERE _TABLE_SUFFIX BETWEEN '2019' AND '2022' to cut it further.
SELECT _TABLE_SUFFIX AS year, COUNT(*) AS trips
FROM `bigquery-public-data.new_york_taxi_trips.tlc_yellow_trips_*`
WHERE total_amount > 500
GROUP BY year
ORDER BY year;Average tip share by payment type in 2022
Cash tips are usually not recorded, so expect a share near zero for code 2.
SELECT
payment_type,
COUNT(*) AS trips,
ROUND(AVG(SAFE_DIVIDE(tip_amount, fare_amount)), 3) AS avg_tip_share
FROM `bigquery-public-data.new_york_taxi_trips.tlc_yellow_trips_2022`
WHERE fare_amount > 0
GROUP BY payment_type
ORDER BY trips DESC;Busiest pickup zones in 2022
Joins trip location ids to the zone table. Both id columns are strings.
SELECT
z.borough,
z.zone_name,
COUNT(*) AS pickups
FROM `bigquery-public-data.new_york_taxi_trips.tlc_yellow_trips_2022` AS t
JOIN `bigquery-public-data.new_york_taxi_trips.taxi_zone_geom` AS z
ON t.pickup_location_id = z.zone_id
GROUP BY z.borough, z.zone_name
ORDER BY pickups DESC
LIMIT 20;Querying it cheaply
- Each yearly table is a coarse partition: query
tlc_yellow_trips_2022, not the wildcard, when one year answers the question. With a wildcard, filter_TABLE_SUFFIX. - Within a table there is no partitioning or clustering, so a filter on
pickup_datetimedoes not reduce bytes. Select only the columns you need. - The largest tables are yellow taxi 2012 and 2014 (45 and 47 GiB). The green and FHV tables are much smaller.
- For repeated work on a few years, copy the columns you use into your own table partitioned by
DATE(pickup_datetime)(see PARTITION BY).
FAQ
How much does it cost to query NYC taxi trips in BigQuery?
A query on one year with a few columns reads 1 to 2 GiB. Reading every column of every yellow taxi year reads 274 GiB, about $1.67 at the $6.25 per TiB on-demand list price before the free TiB. Most analysis fits easily in the free 1 TiB a month.
Is the NYC taxi dataset free?
Yes for storage: the data sits in the bigquery-public-data project and Google pays to store it. You pay for the queries you run from your own project. On-demand, the first 1 TiB scanned each month is free, then you pay per TiB scanned (see BigQuery pricing).
Which years does the BigQuery NYC taxi dataset cover?
Yellow taxi trips from 2011 to 2022, green taxi trips from 2014 to 2022 and for-hire vehicle trips from 2015 to 2017. The 2023 tables exist but are empty, and the last data update was 2023-03-21.
Does the dataset include Uber and Lyft trips?
Only through the for-hire vehicle tables for 2015 to 2017, which record the dispatching base, pickup time or date and zone, without fares or company names. There are no later for-hire trips in this dataset.
Related datasets
All public datasets · BigQuery cost queries · Pricing calculator
