📜  python代码示例中的跨步

📅  最后修改于: 2022-03-11 14:46:44.536000             🧑  作者: Mango

代码示例1
L = pd.Series(range(15))

def gen_strides(a, stride_len=5, window_len=5):
    n_strides = ((a.size-window_len)//stride_len) + 1
    return np.array([a[s:(s+window_len)] for s in np.arange(0, a.size, stride_len)[:n_strides]])

gen_strides(L, stride_len=2, window_len=4)