I have a data frame that looks like this
ACCEL_X ACCEL_Y ACCEL_Z
DATETIME
2021-05-11 16:12:56 160 32 16392
2021-05-11 16:12:57 20 -192 16548
2021-05-11 16:12:57 128 224 16212
2021-05-11 16:12:57 -148 -132 16624
2021-05-11 16:12:57 -40 204 16132
2021-05-11 16:12:57 72 -132 16536
2021-05-11 16:12:57 220 48 16292
2021-05-11 16:12:57 -132 236 16332
2021-05-11 16:12:57 -232 -132 16628
2021-05-11 16:12:57 192 140 16172
2021-05-11 16:12:57 200 -96 16684
2021-05-11 16:12:57 0 64 16020
2021-05-11 16:12:57 -144 -24 16524
2021-05-11 16:12:57 -160 24 16336
2021-05-11 16:12:57 96 56 16252
2021-05-11 16:12:57 68 -44 16544
2021-05-11 16:12:57 12 76 16308
2021-05-11 16:12:57 -228 -132 16668
2021-05-11 16:12:57 72 -96 16244
2021-05-11 16:12:57 48 -96 16536
According to documentation, I can perform sliding window using the second and I've performed a sliding window rolling of 3s with code:
df = df.rolling('3s').mean()
df
which returns,
ACCEL_X ACCEL_Y ACCEL_Z
DATETIME
2021-05-11 16:12:56 160.000000 32.000000 16392.000000
2021-05-11 16:12:57 90.000000 -80.000000 16470.000000
2021-05-11 16:12:57 102.666667 21.333333 16384.000000
2021-05-11 16:12:57 40.000000 -17.000000 16444.000000
2021-05-11 16:12:57 24.000000 27.200000 16381.600000
2021-05-11 16:12:57 32.000000 0.666667 16407.333333
2021-05-11 16:12:57 58.857143 7.428571 16390.857143
2021-05-11 16:12:57 35.000000 36.000000 16383.500000
2021-05-11 16:12:57 5.333333 17.333333 16410.666667
2021-05-11 16:12:57 24.000000 29.600000 16386.800000
2021-05-11 16:12:57 40.000000 18.181818 16413.818182
2021-05-11 16:12:57 36.666667 22.000000 16381.000000
2021-05-11 16:12:57 22.769231 18.461538 16392.000000
2021-05-11 16:12:57 9.714286 18.857143 16388.000000
2021-05-11 16:12:57 15.466667 21.333333 16378.933333
2021-05-11 16:12:57 18.750000 17.250000 16389.250000
2021-05-11 16:12:57 18.352941 20.705882 16384.470588
2021-05-11 16:12:57 4.666667 12.222222 16400.222222
2021-05-11 16:12:57 8.210526 6.526316 16392.000000
2021-05-11 16:12:57 10.200000 1.400000 16399.200000
It comes to my attention when I print df after the sliding window, it returns a different desired result.
As of what I understand on sliding window, it should take 'N seconds, in my case 3s' interval data, and perform mean from it.
As of what I see the 'DATETIME' is exactly the same, it should return the same result. But that's not the case, can anyone enlighten me on how the sliding window on pandas works?
--- EDIT 1 ---
running
df.index.inferred_type == "datetime64"
returns
True