Say I have the following np.array():
[1, 2, 3, 4, 5, 6, 7, 8, 9]
I would like to tile the values across with an offset. In this case we group by three and offset by 1:
[
[1, 2, 3],
[2, 3, 4],
[3, 4, 5],
[4, 5, 6],
[5, 6, 7],
[6, 7, 8],
[7, 8, 9],
]
Is there a built in function to achieve this that leverages C internals of numpy? I'm working with very long arrays and using standard array manipulation with loops has been prohibitively slow.