Answers for "numpy rolling"

0

numpy rolling

def rolling_window(a, window):
    shape = a.shape[:-1] + (a.shape[-1] - window + 1, window)
    strides = a.strides + (a.strides[-1],)
    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