Open lesson

Mission: a lead in a sea of trips

Command palette

This mission workspace keeps code and notes in this browser tab. Export them before closing it. Running code is practice, not an automatic grade for the mission.

Brief

Establish a Spark job baseline and check that a change preserves the correct result.

Imani receives a much larger set of trips. Voss pushes the team to publish the first depot appearing in the results, but Mara requires a verifiable baseline. In the tiny copy, SHELL-02 appears twice at D7 and once at D8. Explain the calculation and prepare a measurement before the fictional meeting. The exercise has no timer.

Your mission

  1. Name the rows remaining after the SHELL-02 filter and the count at each depot.
  2. Name two transformations, one action, and the purpose of explain().
  3. Calculate both medians and the rounded speed ratio.
  4. Explain why D7 is a lead to confirm rather than proof.

How to check your work

  • T1, T2, T3; D7=2 and D8=1.
  • filter and groupBy are transformations; collect is an action; explain shows the plan.
  • 6.1 s versus 4.9 s; about 1.24 times faster.
  • Fictional result needing source checks and correct large-scale processing.

Course example

from statistics import median

baseline_seconds = [6.1, 6.0, 6.3]
candidate_seconds = [4.8, 5.0, 4.9]
baseline_rows = candidate_rows = 3
baseline_median = median(baseline_seconds)
candidate_median = median(candidate_seconds)

print("baseline_median", baseline_median)
print("candidate_median", candidate_median)
print("same_rows", baseline_rows == candidate_rows)
print("speedup", round(baseline_median / candidate_median, 2))

Code

Use Tab to leave the editor. Ctrl+Enter runs the source. The lines beginning with # are task reminders. Python ignores them. Write your code beneath them.

Python console

Loading laboratory…

Explore Python or SQL here; this is not an operating-system shell.

This is a disposable browser experiment. The code run here is not recorded as a completed mission.

Each command starts a fresh disposable worker: it runs a captured copy of your current source, then your command with the lesson fixtures. Changes are discarded afterward. Commands never save source or award XP. Ctrl+Enter executes the command.

Virtual workspace files

Source and declarative assets are readable here without JavaScript. Python input files are created at runtime; SQL setup initializes the disposable database.

source.py

Current editor source. Inspection shows your current edits.

# Name the rows remaining after the SHELL-02 filter and the count at each depot.
# Name two transformations, one action, and the purpose of explain().
# Calculate both medians and the rounded speed ratio.
# Explain why D7 is a lead to confirm rather than proof.

exemple.py

Declarative lesson asset; this is not a file created in the Python filesystem.

from statistics import median

baseline_seconds = [6.1, 6.0, 6.3]
candidate_seconds = [4.8, 5.0, 4.9]
baseline_rows = candidate_rows = 3
baseline_median = median(baseline_seconds)
candidate_median = median(candidate_seconds)

print("baseline_median", baseline_median)
print("candidate_median", candidate_median)
print("same_rows", baseline_rows == candidate_rows)
print("speedup", round(baseline_median / candidate_median, 2))