Get Average By Months Of A Time Series (all Januaries, All Februaries, Etc)
I have a time series of daily data from 1992 to 2018. So far I have converted to monthly data but I also need to obtain anomalies per month and I need to obtain the average of each
Solution 1:
What you need is groupby
:
m = df['Date'].dt.month
result = df.groupby(m).mean()
# Rename month 1 to January, 2 to February, etc.result.index = pd.date_range('1/1/2019', '12/1/2019', freq='MS').strftime('%B')
Result (with random input):
Value
January 51.838811
February 51.455804
March 51.275257
April 52.027894
May 49.101480
June 51.866638
July 51.600765
August 50.416463
September 48.732991
October 51.477874
November 50.797786
December 51.003006
Post a Comment for "Get Average By Months Of A Time Series (all Januaries, All Februaries, Etc)"