create new array from other arrays

I want to create a new array from three other arrays so that I want to create a 20×3 array (center_lab) from three 20×1 arrays (TT2r, TT2g, TT2b) so I would get the following:

center_lab = np.zeros([20,3])

center_lab[:,0] = TT2r 
center_lab[:,1] = TT2g
center_lab[:,2] = TT2b

And I get the next error: could not broadcast input array from shape (21,1) into shape (21,)

Anyone knows how to fix this?


If im not mistaken your TT2r arrays have a shape of (21,1)

The part of center_lab you write into is only of shape (21,) since you index the last dimension (as opposed to slicing). If you also remove the last dimensions of your TTs it should fit.

center_lab = np.zeros([20,3])

center_lab[:,0] = TT2r[:,0]
center_lab[:,1] = TT2g[:,0]
center_lab[:,2] = TT2b[:,0]