Let's say I have got the following numpy array
A = np.array([[0,1,2,3,4],[5,6,7,8,9],[10,11,12,13,14],[15,16,17,18,19],[20,21,22,23,24],[25,26,27,28,29]])
out[]: array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19],
[20, 21, 22, 23, 24],
[25, 26, 27, 28, 29]])
I would like to reorganize it in such a way that the output is
out[] : array([[0,5],
[1,6],
[2,7],
[3,8],
[4,9],
[10,15],
[11,16],
[12,17],
[13,18],
[14,19],
[20,25],
[21,26],
....,
[24,29]])
I have been trying different combinations of np.reshape
, tranpose
, flatten
, np.swapaxes
, but with no success.
The real array has tens or sometimes hundreds of rows.
Originally, the data is given as DataFrame, but I realized that converting to numpy
array could be a better alternative... Can it be done directly using pandas?