7-Day Rolling Signup Average
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
| date | signups |
|---|---|
| 2023-01-01 | 10 |
| 2023-01-02 | 15 |
| 2023-01-03 | 20 |
| 2023-01-04 | 25 |
| 2023-01-05 | 30 |
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 signupsSolve 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