How do I resample a long time series of months and years to a single average (probably non existing) year with monthly averages?

Viewed 48

I'm having trouble with the pd.resample function, I don't even know if this is the right function to use. I have years of data and I want to create a plot for a range of this data. Therefore I want to average the data I have to monthly data and average the months over those year. What I have:

2006-01-10      91
2006-01-20      65
2006-01-30      54
2006-02-10     771
2006-02-20    1916
...
2099-05-20    2416
2099-05-30    2376
2099-06-10    2056
2099-06-20    1901
2099-06-30    1763
Name: rank, Length: 3366, dtype: int32

What I want:

xxxx-01     150
xxxx-02     230
xxxx-03     245
xxxx-04     176

etc.

I've tried:

df.resample('M') 

But this still leaves me with a lot of years. Resampling to 'Y' creates an average per year which I don't want either.

How should I approach this? And is resampling the right function for this?

0 Answers
Related