Reputation: 85
Been trying to take an average of a month worth of data but I wanted to check that:
df=df.resample('M').mean()
Does give the monthly mean and NOT the mean of the last calander day of month
Also I've seen W-Mon
which would give an average of the monday at a frequency of a week. What would be the equivalent to compare the monthly average of October over multiple years.
I thought it would be this- but it doesn't seem to recognise the command
df=df.resample("M-OCT").mean()
Upvotes: 2
Views: 103
Reputation: 210972
try this:
df.assign(y=df.index.year, m=df.index.month).query('m==10').groupby(['y', 'm']).mean()
PS if you need a neat and tested answer please post sample data set and desired output in your question...
Upvotes: 1