Original
a = np.arange(1, 10)
Expected output
b = array([[ 1, 2, 3],
[ 2, 3, 4],
[ 3, 4, 5],
[ 4, 5, 6],
[ 5, 6, 7],
[ 6, 7, 8],
[ 7, 8, 9],
[ 8, 9, 10]])
I can achieve this using
b = np.array([a[i:i+3] for i in range(10-3)])
but I was wondering if anyone knew a numpy vectorized function to avoid the list comprehension and conversion to array