0

So pretend I have this NumPy array:

array = np.array([0,1,2,3,4])

And I want to get all the different sub-arrays with length 3 inside it. The result would look like this:

[[0,1,2], [1,2,3], [2,3,4]]

How can I achieve that?

Rodrigo V
  • 374
  • 1
  • 4
  • 13
  • 3
    Play with [as_strided](https://numpy.org/doc/stable/reference/generated/numpy.lib.stride_tricks.as_strided.html). – Quang Hoang Dec 06 '21 at 19:17

0 Answers0