Typesetting…
Typesetting…
Case study
Data engineering
Abstract
A Python and PostgreSQL pipeline that loads all 40,435,831 NYC yellow taxi trips from 2024 (about 3.9 GB) into a staged, indexed analytics schema and answers demand, revenue and passenger questions in SQL.
Keywords — Python · pandas · PyArrow · PostgreSQL · ETL · SQL analytics · Indexing
Table 1 · At a glance
The NYC Taxi & Limousine Commission publishes a year of yellow taxi trips as twelve monthly Parquet files. Querying them directly is slow and makes repeatable analysis hard. The goal was a reproducible pipeline that turns the raw files into a typed relational schema, then shows how schema design and indexing change query performance at this scale.
Source: NYC TLC Trip Record Data, yellow taxi trips for 2024. Key fields are pickup and drop-off timestamps, passenger count, trip distance, pickup and drop-off taxi zones, base fare and total amount.
| Stage | Description | Size |
|---|---|---|
| Raw Parquet | Monthly TLC files | ~60 MB each |
| Combined dataset | All 2024 yellow taxi trips | ~40 million rows |
| Cleaned CSV | Consolidated input for the ETL | ~3.9 GB |
| PostgreSQL | Rows loaded into the analytics table | 40,435,831 |
phase1_parquet_to_clean_csv.py loads each monthly file, checks the schema is consistent, drops invalid rows, normalizes timestamps and merges the months. It works in chunks so a multi-gigabyte dataset never has to fit in memory.
phase2_postgres_etl.py creates a staging table and bulk-loads the CSV with PostgreSQL COPY, keeping ingestion fast and transformation minimal.
Data is converted to proper types and moved into analytics.yellow_taxi_trips_2024, separating raw ingestion from the cleaned table used for queries.
B-tree indexes on pickup time, pickup zone and the (pickup time, pickup zone) pair support time-range, spatial and combined filters.
Queries cover demand by pickup zone, monthly volume, trip distance, passenger counts and revenue concentration across zones.
Before indexing
~1.2 s
After indexing
~0.05 s
A representative time-filtered query went from about 1.2 seconds to about 0.05 seconds once PostgreSQL could use the pickup-time B-tree index instead of scanning all 40 million rows.
The repository contains both pipeline scripts, the analytical SQL, a processing summary and the full project report.
View GitHub repository ↗