calculating climatology using python pandas -


i have started using pandas , use analysis of time series oceanographic studies. in order calculate anomalies need calculate daily , monthly type of climatology long time series.

by mean: example daily data time series 1992 2012, calculate daily climatology ie (jan-1 data of 1992 +jan-1 data of 1993+ ....jan-1-2012)/number of years , jan 3 etc.

the resulting time series have length of 365 days , each point in average of each day of 20 years 1992 2012.

similarly need calculate monthly climatology, ie mean of januaries of 20 years , mean of febs of 20 years. etc. great if 1 advice me if there quick way in pandas kind of analysis?

with best regards,

sudheer

you can organize series in such way columns years , rows days (month, day tuples below). , use mean() method calculate averages of rows:

in [1]: import pandas pd  in [2]: df = pd.dataframe({2010: [1,2,3,4,5], 2011: [2,3,4,5,6]}, index=[(1,1),(1,2),(1,3),(1,4),(1,5)])  in [3]: df out[4]:          2010  2011 (1, 1)     1     2 (1, 2)     2     3 (1, 3)     3     4 (1, 4)     4     5 (1, 5)     5     6  in [5]: df2 = df.mean(axis=1)  in [6]: df2 out[7]:  (1, 1)    1.5 (1, 2)    2.5 (1, 3)    3.5 (1, 4)    4.5 (1, 5)    5.5 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -