Python
#43

Calculate Rolling 30-Day Moving Averages in Pandas

MediumFlipkart
Interview Question #43
Asked at Flipkart

Given a daily sales DataFrame with a DatetimeIndex and `revenue`, compute a 30-day rolling mean `rolling_mean_30d` and rolling standard deviation `rolling_std_30d`.

Input Table: daily_revenue
2 rows preview
daterevenue
2026-01-0110000
2026-01-0212000
Expected Output Structure1 rows
daterevenuerolling_mean_30d
2026-01-301150011200.5
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

Python 3.10 (Pandas)
Environment Ready

Click "Run & Test" to execute your Pandas code against the test assertions.

Chat with us