python - slicing the pandas data frame with month range -


i working on dataset has years data on pandas data frame. sample given below. data indexed on date column

date                    2013-12-07  6555  10171 2013-06-17  3754  11140 2013-10-02  5278   6986 2014-01-26  4493  10432 2013-11-17  6739   9001 2014-02-28  3708  11540 2013-04-16   262   6616 2013-08-29  5247   7062 2013-09-18  4401   7032 2013-06-13  2739   7386 2014-03-04  5247  11140 2013-07-22  5047   8647 2013-04-04   277   6447 2013-08-09  5508   7155 2013-11-13  5632   9201 

i a sample of 3 months , 6 months data frame. please advice on how best achieve it. thanks

if want extract 3/6 month chunk of data data frame why not truncate?

assuming dataframe called "df":

# 3 month chunk df3 = df.truncate(df.index[0],df.index[0]+3)  # 6 month chunk df6 = df.truncate(df.index[0],df.index[0]+6) 

there ambiguity in question, wonder if mean 3/6 month resampling. if so, quite easy.

df3 = df.resample('3m',how='mean',axis=0) df6 = df.resample('6m',how='mean',axis=0) 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -