3D numpy array sliding window

Viewed 24

I'm currently trying to define a sliding window that would iterate over an 3D array. The dimension of my numpy array is (270,5,22): so in total there are 270 times 5 days with 22 inputs captured. So the first row would have data for (01/09 - 05/09) each with their respective 22 of features. The second row out of the 270 would have data for (06/09 - 10/09) (5,22)

I would like to walk over this data meaning I want to create extra datapoints based on (01/09-05/09),(02/09-06/09),(03/09-07/09) and so on.

I've tried using :

s0,s1,s2 = X_train.strides #40,8,10816
m,n,o = X_train.shape #270,5,22
np.lib.stride_tricks.as_strided(X_train, shape=(y_shape,n,o), strides=(s1,s1,s2))

With y being a shape of :

(2914, _)

Which gives correct results for the beginning but gives me random numbers at the tail of the result. Any idea how to achieve this result or know how to achieve this in pandas ?

0 Answers
Related