pandas dataframe group year index by decade

后端 未结 4 1212
感动是毒
感动是毒 2021-02-06 03:27

suppose I have a dataframe with index as monthy timestep, I know I can use dataframe.groupby(lambda x:x.year) to group monthly data into yearly and apply other oper

4条回答
  •  不知归路
    2021-02-06 04:28

    lets say your date column goes by the name Date, then you can group up

    dataframe.set_index('Date').ix[:,0].resample('10AS', how='count')

    Note: the ix - here chooses the first column in your dataframe

    You get the various offsets: http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases

提交回复
热议问题