I need help with this. I want to get the average of my data over a time interval using a specific time step for example 3 second intervals. So therefore, data is in one second resolution and I want to change the resolution to 3 seconds using the average values.
The Input:
| time | S |
|---|---|
| 2:30:01 | 5 |
| 2:30:02 | 9 |
| 2:30:03 | 450 |
| 2:30:04 | 7 |
| 2:30:05 | 10 |
| 2:30:06 | 300 |
This is what I was thinking... Alas, this is not changing the time intervals and the average isn't at the right index.
import pandas
step = 3 #3 seconds
df = df.groupby(df.index // step).mean()
Note: Please if you think there's another way to approach the problem I'm all ears.
Output:
| time | S |
|---|---|
| 2:30:03 | 154.7 |
| 2:30:06 | 105.7 |