Stretch array (Numpy, Python)
Posted
by Snej
on Stack Overflow
See other posts from Stack Overflow
or by Snej
Published on 2010-03-21T02:38:38Z
Indexed on
2010/03/21
2:41 UTC
Read the original article
Hit count: 522
I have a numpy array [1,2,3,4,5,6,7,8,9,10,11,12,13,14]
and want to have an array structured like [[1,2,3,4], [2,3,4,5], [3,4,5,6], ..., [11,12,13,14]]
.
Sure this is possible by looping over the large array and adding arrays of length four to the new array, but I'm curious if there is some secret 'magic' Python method doing just this :)
© Stack Overflow or respective owner