A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://numpy.org/doc/stable/reference/generated/numpy.moveaxis.html below:

numpy.moveaxis — NumPy v2.3 Manual

numpy.moveaxis#
numpy.moveaxis(a, source, destination)[source]#

Move axes of an array to new positions.

Other axes remain in their original order.

Parameters:
anp.ndarray

The array whose axes should be reordered.

sourceint or sequence of int

Original positions of the axes to move. These must be unique.

destinationint or sequence of int

Destination positions for each of the original axes. These must also be unique.

Returns:
resultnp.ndarray

Array with moved axes. This array is a view of the input array.

See also

transpose

Permute the dimensions of an array.

swapaxes

Interchange two axes of an array.

Examples

>>> import numpy as np
>>> x = np.zeros((3, 4, 5))
>>> np.moveaxis(x, 0, -1).shape
(4, 5, 3)
>>> np.moveaxis(x, -1, 0).shape
(5, 3, 4)

These all achieve the same result:

>>> np.transpose(x).shape
(5, 4, 3)
>>> np.swapaxes(x, 0, -1).shape
(5, 4, 3)
>>> np.moveaxis(x, [0, 1], [-1, -2]).shape
(5, 4, 3)
>>> np.moveaxis(x, [0, 1, 2], [-1, -2, -3]).shape
(5, 4, 3)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4