I work with monthly climate data (e.g. monthly mean temperature or precipitation) where I am often interested in taking several-month means e.g. December-March or May-September. To do this, I'm attempting to aggregrate monthly time series data using offsets in pandas (version 1.3.5) following the documentation.
For example, I have a monthly time series:
import pandas as pd
index = pd.date_range(start="2000-01-31", end="2000-12-31", freq="M")
data = pd.Series(range(12), index=index)
Taking a 4-month mean:
data_4M = data.resample("4M").mean()
>>> data_4M
2000-01-31 0.0
2000-05-31 2.5
2000-09-30 6.5
2001-01-31 10.0
Freq: 4M, dtype: float64
Attempting a 4-month mean with a 2-month offset produces a warning with the same results as the no-offset example above:
data_4M_offset = data.resample("4M", offset="2M").mean()
c:\program files\python39\lib\site-packages\pandas\core\resample.py:1381: FutureWarning: Units 'M', 'Y' and 'y' do not represent unambiguous timedelta values and will be removed in a future version
tg = TimeGrouper(**kwds)
>>> data_4M_offset
2000-01-31 0.0
2000-05-31 2.5
2000-09-30 6.5
2001-01-31 10.0
Freq: 4M, dtype: float64
Does this mean that the monthly offset functionality has already been removed? Is there another way that I can take multi-month averages with offsets?