How can I group by a 10 second group in pandas

Viewed 2730

I have data that is collected every 10 seconds. I want to group by a 10 second group to compare against each group. So I'll have 6 groups (00, 10, 20, 30, 40, 50). Then I can use a box plot for each series/group.

I tried using a grouper but without success.

groups = df.reset_index().groupby(pd.Grouper(key='date', freq='10s', axis=1))

Here is a small sample of the data.

                      value
date                       
2012-01-01 01:00:00    5.0
2012-01-01 01:00:10   16.5
2012-01-01 01:00:20   28.5
2012-01-01 01:00:30   40.5
2012-01-01 01:00:40   43.2     
2012-01-01 01:00:50   33.2 
2012-01-01 01:01:00   15.0
2012-01-01 01:01:10   14.5
2012-01-01 01:01:20   38.5
2012-01-01 01:01:30   30.5
2012-01-01 01:01:40   33.2     
2012-01-01 01:01:50   23.2 
3 Answers
Related