Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

numpy rolling 2d

def rolling_window(a, window_size):
    shape = (a.shape[0] - window_size + 1, window_size) + a.shape[1:]
    strides = (a.strides[0],) + a.strides
    return np.lib.stride_tricks.as_strided(a, shape=shape, strides=strides)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #numpy #rolling
ADD COMMENT
Topic
Name
5+4 =