Resample Daily Metrics to Monthly
Problem
**[Asked at Snowflake]**
Aggregate daily values into monthly totals using pandas resampling.
Return columns: `month` (YYYY-MM), `total`. Order by month.
Input data
Example rows — the live problem includes the full dataset.
metrics
| date | value |
|---|---|
| 2023-01-05 | 100 |
| 2023-01-15 | 150 |
| 2023-01-25 | 200 |
| 2023-02-03 | 50 |
| 2023-02-18 | 75 |
Expected output
Your answer should return 3 rows with the columns month, total.
Starter code (Pandas (Python))
import pandas as pd
def resample_monthly(metrics: pd.DataFrame) -> pd.DataFrame:
# Your code here
return metricsSolve 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