cf.Data.swapaxes

Data.swapaxes(axis0, axis1, inplace=False, i=False)[source]

Interchange two axes of an array.

See also

flatten', `flip, ‘insert_dimension`, squeeze, transpose

Parameters
axis0, axis1int, int

Select the axes to swap. Each axis is identified by its original integer position.

inplace: bool, optional

If True then do the operation in-place and return None.

i: deprecated at version 3.0.0

Use the inplace parameter instead.

Returns
Data or None

The data with swapped axis positions.

Examples

>>> d = cf.Data([[[1, 2, 3], [4, 5, 6]]])
>>> d
<CF Data(1, 2, 3): [[[1, ..., 6]]]>
>>> d.swapaxes(1, 0)
<CF Data(2, 1, 3): [[[1, ..., 6]]]>
>>> d.swapaxes(0, -1)
<CF Data(3, 2, 1): [[[1, ..., 6]]]>
>>> d.swapaxes(1, 1)
<CF Data(1, 2, 3): [[[1, ..., 6]]]>
>>> d.swapaxes(-1, -1)
<CF Data(1, 2, 3): [[[1, ..., 6]]]>