AnalystPath

7-Day Rolling Signup Average

PandasMediumMid level~15 min

Problem

**[Classic — growth analytics]**

Compute a **7-day rolling average** of daily signups (the current day plus
up to 6 preceding days; use `min_periods=1` so early days are not NaN).

Return `date`, `signups`, `rolling_avg` (rounded to 2 dp), ordered by date.

Input data

Example rows — the live problem includes the full dataset.

signups
datesignups
2023-01-0110
2023-01-0215
2023-01-0320
2023-01-0425
2023-01-0530

Expected output

Your answer should return 10 rows with the columns date, signups, rolling_avg.

Starter code (Pandas (Python))

import pandas as pd

def rolling_signups(signups: pd.DataFrame) -> pd.DataFrame:
    # Your code here
    return signups

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