larray.Array.rename
- Array.rename(renames=None, to=None, inplace=False, **kwargs) Array [source]
Rename axes of the array.
- Parameters
- renamesaxis ref or dict {axis ref: str} or list of tuple (axis ref, str)
Rename to apply. If a single axis reference is given, the to argument must be used.
- tostr or Axis
New name if renames contains a single axis reference.
- **kwargsstr or Axis
New name for each axis given as a keyword argument.
- Returns
- Array
Array with axes renamed.
See also
set_axes
replace one or several axes
Examples
>>> nat = Axis('nat=BE,FO') >>> sex = Axis('sex=M,F') >>> arr = ndtest([nat, sex]) >>> arr nat\sex M F BE 0 1 FO 2 3 >>> arr.rename(nat, 'nat2') nat2\sex M F BE 0 1 FO 2 3 >>> arr.rename(nat='nat2', sex='sex2') nat2\sex2 M F BE 0 1 FO 2 3 >>> arr.rename([('nat', 'nat2'), ('sex', 'sex2')]) nat2\sex2 M F BE 0 1 FO 2 3 >>> arr.rename({'nat': 'nat2', 'sex': 'sex2'}) nat2\sex2 M F BE 0 1 FO 2 3