How to group DataFrame by a period of time?

后端 未结 3 1570
Happy的楠姐
Happy的楠姐 2020-11-30 02:40

I have some data from log files and would like to group entries by a minute:

 def gen(date, count=10):
     while count > 0:
         yield date, \"event{         


        
3条回答
  •  借酒劲吻你
    2020-11-30 03:30

    Since the original answer is rather old and pandas introduced periods a different solution is nowadays:

    df.groupby(df.index.to_period('T'))
    

    Additionally, you can resample

    df.resample('T')
    

提交回复
热议问题