I want to stack n
number of columns as new rows at the end of the array. I was trying to do it with reshape but I couldn't make it. For example given the table
table = np.array([[11,12,13,14,15,16],
[21,22,23,24,25,26],
[31,32,33,34,35,36],
[41,42,43,44,45,46]])
my output if n=2
should be:
array([[11, 12],
[21, 22],
[31, 32],
[41, 42],
[13, 14],
[23, 24],
[33, 34],
[43, 44],
[15, 16],
[25, 26],
[35, 36],
[45, 46]])
and if n=3
:
array([[11, 12, 13],
[21, 22, 23],
[31, 32, 33],
[41, 42, 43],
[14, 15, 16],
[24, 25. 26],
[34, 35, 36],
[44, 45, 46]])
Update:
Ok,I managed to achieve the result that I want with the following command:
import numpy as np
n=2
np.concatenate(np.split(table, table.shape[1]/n, axis=1), axis=0)
n=3
np.concatenate(np.split(table, table.shape[1]/n, axis=1), axis=0)
I do not know though if it is possible to be done with reshape.