Time Series Resample

Hard
pandas Uber Netflix Spotify

Given a list of {"date": "YYYY-MM-DD", "value": float} dictionaries, resample by month and return the monthly averages as {"month": "YYYY-MM", "avg": float}.

Example

data = [
  {"date": "2024-01-05", "value": 10},
  {"date": "2024-01-15", "value": 20},
  {"date": "2024-02-10", "value": 30}
]
resample_monthly_avg(data)
# => [{"month": "2024-01", "avg": 15.0}, {"month": "2024-02", "avg": 30.0}]

Test Cases

Python Editor

Output

Click "Run" to see results...