AnalystPath

Next-Day Workout Retention

PandasHardSenior level~10 min

Problem

A fitness app records each workout session a member logs in a DataFrame `workout_log` (`workout_log.csv`).

```text
+-------------+--------+
| Column | Type |
+-------------+--------+
| member_id | int |
| device_id | int |
| log_date | object |
| minutes | int |
+-------------+--------+
```

There may be several rows per member. Each row records one day on which the member logged a workout. A member's signup date is the earliest `log_date` they have.

Write a function that reports, for each signup date, how many members signed up on that date (`signups`) and the fraction of those members who logged another workout on the very next day (`next_day_rate`), rounded to 2 decimal places. Return columns `signup_date`, `signups`, and `next_day_rate` in any order.

Input data

Example rows — the live problem includes the full dataset.

workout_log
member_iddevice_idlog_dateminutes
122022-03-0145
122022-03-0230
232022-04-1020
312022-03-010
342022-06-1550

Expected output

Your answer should return 3 rows with the columns signup_date, signups, next_day_rate.

Starter code (Pandas (Python))

import pandas as pd

def next_day_retention(workout_log: pd.DataFrame) -> pd.DataFrame:
    # Your code here
    return workout_log

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