Let us look at this stupid example with a N0 x N1 x ... x Nm dimensional array, such as
import numpy as np
x = np.random.random([N0,N1,...,Nm])
Now I want the N0 dimension to be behind the last one, i.e.
np.swapaxis np.swapaxis(np.swapaxis(x, 0,1),1,2) ... # swapping m times
I tried with np.rollaxis, but this seems to be the wrong function. In the end, I want to have an array with shape (N1,N2,N3,...,Nm,N0).
Any nice ideas?
I tried with np.rollaxis, but this seems to be the wrong function.
No, it's the right function.
x = numpy.rollaxis(x, 0, x.ndim)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With