Reputation: 141
How do I resample monthly data to yearly data but starting from 1st October.
I tried the following as I know using base works for starting at a certain hour of a day but doesnt appear to work for month of the year.
df = (df.resample(rule='Y', base=10).sum().reset_index())
Upvotes: 1
Views: 2621
Reputation: 4186
Pandas has anchored offsets available for annual resamples starting at the first of a month.
The anchored offset for annual resampling starting in October is AS-OCT
. Resampling and summing can be done like this:
df.resample("AS-OCT").sum()
Upvotes: 2
Reputation: 141
Here is how you do it:
offset = pd.DateOffset(months=9)
df.shift(freq=-offset).resample('YS').sum().shift(freq=offset)
Upvotes: 2