numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
swapaxes(a, axis1, axis2)

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.

Interchange two axes of an array.

Examples

>>> x = np.array([[1,2,3]])
... np.swapaxes(x,0,1) array([[1], [2], [3]])
>>> x = np.array([[[0,1],[2,3]],[[4,5],[6,7]]])
... x array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]])
>>> np.swapaxes(x,0,2)
array([[[0, 4],
        [2, 6]],
       [[1, 5],
        [3, 7]]])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

dask.array.routines.swapaxes dask.array.numpy_compat.moveaxis dask.array.core.Array.swapaxes numpy.moveaxis numpy.ma.core.swapaxes

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/core/fromnumeric.py#550
type: <class 'function'>
Commit: