Module · 5 lessons

DataFrames & Transformations

Stop watching Spark and start driving it. Master the DataFrame API on real data — columns and expressions, filtering and cleaning the taxi dataset's genuine dirt, joining the zone dimension with a broadcast, and grouping and aggregating — then rebuild the previous course's entire zone-hour report in Spark and match it to the cent.

At a glance

Level
Intermediate
Lessons
5 lessons
Time to complete
1 week
Cost
Free forever · no sign-up

Welcome to DataFrames & Transformations, the third module — where you stop watching Spark and start driving it. The first two modules were about understanding: the ceiling that makes distributed engines necessary, and the machinery underneath Spark — lazy plans, RDDs, the DAG, lineage. You can now predict what Spark will do. This module makes you fluent enough to tell it what to do, correctly, on data that fights back. The DataFrame API is the tool you’ll use every working day, and it rewards knowing it well: expressed cleanly, a transformation is something Catalyst can optimize; expressed carelessly, it’s a shuffle you didn’t need or a filter that quietly corrupts a total.

The through-line is CityFlow’s real taxi quarter, and the data’s genuine defects are the point rather than a distraction. You’ll build derived columns — trip duration, fare-per-mile, pickup hour — with column expressions that are themselves lazy plan nodes. You’ll filter and clean in Spark, and the central lesson there is restraint: the dataset’s tens of thousands of negative fares are accounting reversals, not errors, and a filter that drops them overstates revenue by a measured six figures a month. You’ll join the 265-row zone dimension with a broadcast that skips the shuffle entirely, and you’ll key that join on the numeric ID because two different zones are both named “Corona.” And you’ll group and aggregate per zone and per hour, the wide transformation the whole report is built on.

Then the module pays off everything before it. The guided project rebuilds Course 1’s entire zone-hour report — the capstone of the previous course, which pandas and multiprocessing produced under a memory budget — in idiomatic Spark, and cross-verifies it to the cent: 240,917 buckets, 9,554,757 trips, $256,692,373.14. Same answer, same real data, a cluster-scale tool. Start with Lesson 1, where a column turns out to be not a list of values but an expression waiting to be planned.

Lessons in this module

1 Columns & Expressions Learn the Spark Column as an expression, not a list of values, and build real derived columns on 9.5M taxi trips — trip duration (19.8 min on the first trip), fare-per-mile ($13.20), and pickup hour — while defusing the timestamp_ntz cast trap that silently makes a duration 1,000,000x wrong. 2 Filtering & Cleaning Clean the real taxi dirt in Spark without corrupting it: the quarter window drops 21 stray rows, but dropping the 115,894 negative-total reversals invents $2,986,808.76 of revenue CityFlow never earned. 3 Joins Attach borough and zone names to 9,554,757 real taxi trips by joining the 265-row zone lookup on PULocationID = LocationID, broadcast the tiny dimension to skip the shuffle (0.579 s vs 1.362 s sort-merge, 2.35x), and key on the ID because two zones are both named Corona. 4 GroupBy & Aggregation Roll 9,554,757 real taxi trips into 262 per-zone rows with one groupBy().agg() pass — trips, revenue, avg fare, distinct hours — then cross-check the quarter's $256,692,373.14 to the cent and read the map-side pre-aggregation that makes it scale. 5 Guided Project: The Zone-Hour Report in Spark Rebuild Course 1's entire per-zone, per-hour taxi report in idiomatic Spark — read three months, window-filter while keeping the accounting reversals, derive the pickup hour, groupBy(zone, hour) for trips and revenue, broadcast-join the 265-row zone dimension on LocationID — and cross-verify it to the digit: 240,917 buckets, 9,554,757 trips, $256,692,373.14.
Achievement

Complete all 5 lessons to finish the DataFrames & Transformations module.

Start module
Sponsor

Keep DATATWEETS free. Help fund practical data, AI, and engineering lessons for learners worldwide.

Buy Me a Coffee at ko-fi.com