我的数据看起来像:
1495573445.162, 0, 0.021973, 0.012283, -0.995468, 1
1495573445.172, 0, 0.021072, 0.013779, -0.994308, 1
1495573445.182, 0, 0.020157, 0.015717, -0.995575, 1
1495573445.192, 0, 0.017883, 0.012756, -0.993927, 1
1495573445.202, 0, 0.021194, 0.012161, -0.994705, 1
1495573445.212, 0, 0.019638, 0.013718, -0.994019, 1
1495573445.222, 0, 0.019440, 0.010803, -0.994476, 1
1495573445.232, 0, 0.018112, 0.010849, -0.993073, 1
1495573445.242, 0, 0.020157, 0.011154, -0.994644, 1
1495573445.252, 0, 0.020340, 0.010040, -0.995804, 1
1495573445.262, 0, 0.017792, 0.009857, -0.996078, 1
1495573445.272, 0, 0.020538, 0.010239, -0.994858, 1
这是加速度计数据,其中数据框列标记为"Time stamp"
,"Time skipped"
,"x"
,"y"
,"z"
和"label"
索引设置为"Time stamp"
。
采样率约为100Hz。在这种情况下我应该如何创建滑动窗口?
我想出了这个:
def sliding_window(data, window_size, step_size):
data = pd.rolling_window(data, window_size)
data = data[step_size - 1 :: step_size]
print data
return data
我怀疑这是正确的实现,并且我不知道如何设置window_size和step_size,因为我有100Hz的采样率。