mirror of
https://github.com/webclinic017/drift.git
synced 2026-07-28 03:08:01 +00:00
6 lines
231 B
Python
6 lines
231 B
Python
import numpy as np
|
|
|
|
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) |