Reputation: 229
I have a data frame that looks like this:
df.index.dtype
The problem is resampling the data and getting correct results on different time periods.
e.g:
# count frame drops per second - works correctly
df.to_period(freq='S').groupby('ts')['frame_drop_issue'].sum()
# count frame drops per minute - works correctly
df.to_period(freq='T').groupby('ts')['frame_drop_issue'].sum()
But, if I try to aggregate by a period of 2 seconds, I get wrong results (similar as one second result)
# count frame drops per 2 seconds- wrong result
df.to_period(freq='2S').groupby('ts')['frame_drop_issue'].sum()
What am i doing wrong?
Upvotes: 0
Views: 53
Reputation: 1921
to_period
probably doesn't work with multiples of frequency. It's still an open issue
https://github.com/pandas-dev/pandas/issues/14070.
Instead you can use resample
.
df.resample('2S')['frame_drop_issue'].sum()
Upvotes: 1