AnalystPath

Streaming Subscribers on a Hot Streak

PandasMediumMid level~10 min

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.

subscribers
sub_idhandle
1mara
7devi
opens
sub_idopen_day
72021-04-30
12021-04-30
72021-05-01
72021-05-02
72021-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 subscribers

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