This is a pre-release version (latest). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy latest / numpy / swapaxes

_ArrayFunctionDispatcher

numpy:swapaxes

source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/fromnumeric.py :552

Signature

def   swapaxes ( a axis1 axis2 )

Summary

Interchange two axes of an array.

Parameters

a : array_like

Input array.

axis1 : int

First axis.

axis2 : int

Second axis.

Returns

a_swapped : ndarray

For NumPy >= 1.10.0, if a is an ndarray, then a view of a is returned; otherwise a new array is created. For earlier NumPy versions a view of a is returned only if the order of the axes is changed, otherwise the input array is returned.

Examples

import numpy as np
x = np.array([[1,2,3]])
np.swapaxes(x,0,1)
x = np.array([[[0,1],[2,3]],[[4,5],[6,7]]])
x
np.swapaxes(x,0,2)

Aliases

  • numpy.swapaxes