import numpy as np
from numpy.lib import stride_tricks
# Define rolling function using stride_tricks
def rolling(a, window):
shape = (a.size - window + 1, window)
strides = (a.itemsize, a.itemsize)
return stride_tricks.as_strided(a, shape=shape, strides=strides)
# Create an array of integers from 0 to 9 using np.arange
# then apply the rolling function with window size 3
Z = rolling(np.arange(10), 3)
print(Z)