cf.Data.transpose

Data.transpose(axes=None)[source]

Permute the dimensions of the data array in place.

Parameters :
axes : (sequence of) int or str, optional

The new axis order of the data array. By default the order is reversed. Each axis of the new order is identified in turn as one of:

  • An internal axis identifier. Selects this axis.
  • An integer. Selects the axis coresponding to the given position in the list of axes of the data array.
Returns :
out : list of ints

The axes which were transposed

See also

expand_dims, flip, squeeze

Examples

>>> d.ndim
3
>>> d.shape
(19, 73, 96)
>>> d.dimensions
['dim0', 'dim1', 'dim2']
>>> d.transpose()
>>> d.shape
(96, 73, 19)
>>> d.transpose([1, 0, 2])
>>> d.shape
(73, 96, 19)
>>> d.transpose(['dim2', 'dim0', 'dim1'])
>>> d.shape
(96, 19, 73)
>>> d.dimensions
['dim2', 'dim0', 'dim1']
>>> d.transpose((1,  'dim1', 0))
>>> d.shape
(19, 73, 96)

Previous topic

cf.Data.to_memory

Next topic

cf.Data.__lt__

This Page