Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

NYC Taxi Trip Analysis with Apache Spark

Distributed data processing of the NYC Yellow Taxi Trip Records (March 2016) using PySpark — covering RDDs, Spark SQL, and DataFrames.

📘 Course: INFT 4836 — Intro to Big Data Analytics | ADA University


Dataset

NYC Yellow Taxi Trip Records — March 2016

  • 12+ million rows of real-world transportation data
  • Fields include: VendorID, pickup datetime, trip distance, passenger count, fare amount, payment type

Dataset download: NYC TLC Trip Records — March 2016 Yellow Taxi CSV


Tasks

Task 1 — Spark RDDs

Core transformations and actions applied to the raw dataset:

Operation Purpose
filter() Remove trips where trip_distance == 0 (cancelled/erroneous rides)
map() Extract (VendorID, TripDistance) tuples
flatMap() Split pickup datetime into [Date, Time] tokens
reduceByKey() Sum total distance driven per vendor
collect() Retrieve results to driver

Results:

result_rdd

Task 2 — Spark SQL

Registered the DataFrame as a temp view taxi_trips and ran three queries:

Query 1 — Average fare and trip count grouped by passenger count:

result_sql1

Query 2 — High-value trips: fare > $50 AND distance > 10 miles:

result_sql2

Query 3 — Payment type join with human-readable labels:

result_sql3

Task 3 — Spark DataFrames

Data Cleaning — Dropped nulls from passenger_count, trip_distance, fare_amount — row count unchanged, confirming no nulls in these columns.

GroupBy + Aggregation — Statistical summaries grouped by VendorID.

Sorting & Insights — Sorted by passenger_count ASC and fare_amount DESC, revealing significant data quality issues:

result_df_sort
  • 608 trips recorded with 0 passengers, some with fares over $200
  • Extreme outlier: 1 trip with 1 passenger charged $429,496.72 for 0.0 miles

Conclusion: The dataset was null-free but contained logical errors and extreme outliers — highlighting the need for business-rule-based cleaning beyond standard null checks.


Setup

Requirements

  • Python 3.x
  • Java 17 (set JAVA_HOME explicitly to avoid version conflicts)
  • Apache Spark / PySpark
pip install pyspark

Run

spark-submit analysis.py

Or run interactively in a Jupyter notebook.


Folder Structure

├── analysis.py        # Main PySpark script
├── screenshots/       # Result screenshots
└── README.md

Author

Rashad Hummatov — Computer Engineering, ADA University
GitHub

About

Distributed analysis of 12M+ NYC taxi trips using PySpark RDDs, Spark SQL, and DataFrames

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages