The Sales Leaderboard Rebuild
PySpark · Advanced · about 30 minutes
Mission
The regional sales leaderboard is wrong. A reporting job exported some transactions twice, so several totals are inflated and the rankings cannot be trusted. Rebuild it in PySpark: clean the feed, total each salesperson's sales within their region, and publish only the two strongest sellers per region. Each step feeds the next, so the order of the steps matters as much as the code inside them.
Objective
Produce a DataFrame with region, salesperson and total_sales that holds at most two rows per region, and finish with .show() as the challenge requires.
Skills involved
- Deduplicating before aggregating
- Grouped aggregation
- Ranking within a partition
- Top-N filtering per group
Suggested preparation
Preparation is optional. The battle is written and graded in the regular challenge editor: open the battle challenge.