3d array into 2d array python

#n x m x 3 is to be converted to 3 x (n*m),
img.transpose(2,0,1).reshape(3,-1)

Here is what the above code is Doing:
1. img.transpose(2,0,1) – This is converting the image to a 3D array.
2. .reshape(3,-1) – This is flattening the 3D array to a 1D array.