Answers for "numpy rolling 2d"

0

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)
Posted by: Guest on May-15-2021

Python Answers by Framework

Browse Popular Code Answers by Language