'Reshaping numpy array without changing the data

I'm trying to reshape an array of bitmap images that has a shape of (50,50,90000). How can I modify it so that I can get an array of (90000,50,50)? - I tried array.reshape(90000,50,50), or np.reshape(array, (90000,50,50), order='C' /'F'), but these options changed the order of the data so I couldn't get the images after using these.



Solution 1:[1]

Try np.moveaxis, e.g. like so:

np.moveaxis(arr, 0, 2)

There's also np.swapaxes if that suits your needs better.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kwinkunks