I want to modify this SO topic here to three hourly interval. I have a database of events at minute resolution. I need to group them in three hourly, and extract the count of this grouping.
The output would ideally look something like a table like the following:
3hourly count
0 10
3 3
6 5
9 2
...
答案 0 :(得分:6)
您还没有提供太多详细信息,但您可以使用' TimeGrouper':
df.groupby(pd.TimeGrouper(key='your_time_column', freq='3H')).count()
如果你的时间是索引,key
参数是可选的。