pandas dataframe group year index by decade

后端 未结 4 1298
感动是毒
感动是毒 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:04

    if your Data Frame has Headers say : DataFrame ['Population','Salary','vehicle count']

    Make your index as Year: DataFrame=DataFrame.set_index('Year')

    use below code to resample data in decade of 10 years and also gives you some of all other columns within that dacade

    datafame=dataframe.resample('10AS').sum()

提交回复
热议问题