bundles / numpy 2.4.3 / numpy / moveaxis
_ArrayFunctionDispatcher
numpy:moveaxis
source: /numpy/_core/numeric.py :1493
Signature
def moveaxis ( a , source , destination ) Summary
Move axes of an array to new positions.
Extended Summary
Other axes remain in their original order.
Parameters
a: np.ndarrayThe array whose axes should be reordered.
source: int or sequence of intOriginal positions of the axes to move. These must be unique.
destination: int or sequence of intDestination positions for each of the original axes. These must also be unique.
Returns
result: np.ndarrayArray with moved axes. This array is a view of the input array.
Examples
import numpy as np x = np.zeros((3, 4, 5)) np.moveaxis(x, 0, -1).shape np.moveaxis(x, -1, 0).shape✓
np.transpose(x).shape np.swapaxes(x, 0, -1).shape np.moveaxis(x, [0, 1], [-1, -2]).shape np.moveaxis(x, [0, 1, 2], [-1, -2, -3]).shape✓
See also
- swapaxes
Interchange two axes of an array.
- transpose
Permute the dimensions of an array.
Aliases
-
numpy.moveaxis