How can a get a 2D array containing all possible consecutive sub-arrays of a certain length?
For example, say my array was ['a', 'b', 'c', 'd', 'e']
, and n was 3, the result should be
[['a', 'b', 'c']
['b', 'c', 'd']
['c', 'd', 'e']]
I found a similar question relating to python lists, however I'd like to do this with numpy, as I need to perform this on many different arrays, each of which are fairly large. Basically, speed is an issue here.