I have a DataFrame of different time series of different Trials of an experiment. the data contains columns of a vehicle's acceleration state. the states are -1 for deceleration, 0 for brake, 1 for acceleration.
I want to make a summary of every -1,0,1, and a need a way to group all the adjacent 1's while disregarding the other 1's. and the same for 0 and -1.
for example: this is what I have:
| X axis acceleration | X axis state |
|---|---|
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0.87 | 1 |
| 0.88 | 1 |
| 0 | 0 |
| -0.28 | -1 |
| -0.27 | -1 |
| 0 | 0 |
| 0 | 0 |
| 0.46 | 1 |
| 0.23 | 1 |
This what I want to get:
| mean X axis acceleration | X axis state | event number |
|---|---|---|
| 0 | 0 | 1 |
| 0.875 | 1 | 2 |
| 0 | 0 | 3 |
| -0.275 | -1 | 4 |
| 0 | 0 | 5 |
| 0.345 | 1 | 6 |