I have a numpy array of size 5000x32x32x3. The number 5000 is the number of images and each image is 32x32 in width and height and has 3 color channels.
Now I would like to create a numpy array  of shape 5000x3x32x32 in a way that the data is preserved.
What I mean by preserving data is :
- There should be 5000 data points in the resulting array
- The 2nd dimension (3) of the array correctly determines the color channel i.e all the elements whose 2nd dimension is0belong to red channel, whose 2nd dimension is1belong to green channel,whose 2nd dimension is2belong to blue channel.
Simply reshaping the by np.reshape(data,(5000,3,32,32)) would not work as it would not preserve the channels but just reshape the data into the desired shape.

numpy.swapaxesdocs.scipy.org/doc/numpy/reference/generated/… . It should be doable by two axes transpositions.np.transpose(data, (0,3,1,2))should do what you want.