larray.AxisCollection.rename

AxisCollection.rename(renames=None, to=None, **kwargs) AxisCollection[source]

Rename axes of the collection.

Parameters
renamesaxis ref or dict {axis ref: str} or list of tuple (axis ref, str), optional

Rename to apply. If a single axis reference is given, the to argument must be used.

tostr or Axis, optional

New name if renames contains a single axis reference.

**kwargsstr or Axis

New name for each axis given as a keyword argument.

Returns
AxisCollection

collection with axes renamed.

Examples

>>> nat = Axis('nat=BE,FO')
>>> sex = Axis('sex=M,F')
>>> axes = AxisCollection([nat, sex])
>>> axes
AxisCollection([
    Axis(['BE', 'FO'], 'nat'),
    Axis(['M', 'F'], 'sex')
])
>>> axes.rename(nat, 'nat2')
AxisCollection([
    Axis(['BE', 'FO'], 'nat2'),
    Axis(['M', 'F'], 'sex')
])
>>> axes.rename(nat='nat2', sex='sex2')
AxisCollection([
    Axis(['BE', 'FO'], 'nat2'),
    Axis(['M', 'F'], 'sex2')
])
>>> axes.rename([('nat', 'nat2'), ('sex', 'sex2')])
AxisCollection([
    Axis(['BE', 'FO'], 'nat2'),
    Axis(['M', 'F'], 'sex2')
])
>>> axes.rename({'nat': 'nat2', 'sex': 'sex2'})
AxisCollection([
    Axis(['BE', 'FO'], 'nat2'),
    Axis(['M', 'F'], 'sex2')
])