AnalystPath

Breakthrough Third Session

PandasMediumMid level~10 min

Problem

You are given a DataFrame `workout` with columns `athlete_id`, `distance_km`, and `logged_at`. There is no single-column key; the pair `(athlete_id, logged_at)` is unique. Each row is one logged workout for an athlete.

For every athlete, look at their third workout in chronological order (by `logged_at`). Keep that workout only if its `distance_km` is strictly greater than both the athlete's first and second workouts. Return `athlete_id`, the third workout's distance as `breakthrough_distance`, and its timestamp as `breakthrough_at`, ordered by `athlete_id`.

Input data

Example rows — the live problem includes the full dataset.

workout
athlete_iddistance_kmlogged_at
13.002024-01-01 06:00:00
14.502024-01-03 06:00:00
16.202024-01-05 06:00:00
28.002024-01-02 07:00:00
25.002024-01-04 07:00:00

Expected output

Your answer should return 1 row with the columns athlete_id, breakthrough_distance, breakthrough_at.

Starter code (Pandas (Python))

import pandas as pd

def breakthrough_third_session(workout) -> pd.DataFrame:
    # Your code here
    return workout

Solve this Pandas question free

Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related Pandas questions