Datetime group in panda at three o'clock

I want to change this SOA theme here to a three hour interval. I have an event database with minimal resolution. I need to group them for three hours and extract the account of this grouping.

The result would ideally look like a table like the following:

3hourly    count
0          10
3          3
6          5
9          2
...
+4
source share
1 answer

You did not specify a lot of details, but you can use "TimeGrouper":

df.groupby(pd.TimeGrouper(key='your_time_column', freq='3H')).count()

The parameter keyis optional if your time is an index.

+5
source

All Articles