Streaming Subscribers on a Hot Streak
Problem
A music app records the days on which each subscriber opened the app.
DataFrame `subscribers` (from `subscribers.csv`) has columns `sub_id` (primary key) and `handle` (display name).
DataFrame `opens` (from `opens.csv`) has columns `sub_id` and `open_day` (date). This DataFrame may contain duplicate rows — a subscriber can open the app many times on the same day.
A subscriber is on a hot streak if they opened the app on five or more consecutive calendar days. Report the `sub_id` and `handle` of every such subscriber, ordered by `sub_id`.
Input data
Example rows — the live problem includes the full dataset.
| sub_id | handle |
|---|---|
| 1 | mara |
| 7 | devi |
| sub_id | open_day |
|---|---|
| 7 | 2021-04-30 |
| 1 | 2021-04-30 |
| 7 | 2021-05-01 |
| 7 | 2021-05-02 |
| 7 | 2021-05-03 |
Expected output
Your answer should return 1 row with the columns sub_id, handle.
Starter code (Pandas (Python))
import pandas as pd
def hot_streak_subscribers(subscribers, opens) -> pd.DataFrame:
# Your code here
return subscribersSolve 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