Pandas/Time series 9 min

Resampling

Roll daily rows up to weeks, months or quarters.

resamplemonthly

resample is groupby for time. With a datetime index you give it a frequency — D, W, M, Q — and an aggregation.

python · editable
loading editor…

Try it: Switch to monthly totals with 'ME'.

agg gives several statistics per period at once, and grouping by a second key alongside the frequency produces a per-region time series.

python · editable
loading editor…

Upsampling to a finer frequency creates gaps — decide explicitly whether to ffill, interpolate or leave them as NaN.

practice this