rename_variable#
- pypillometry.rename_variable(old, new, eyes=[], overwrite=False)#
Pipeline step for
rename_variable()(d | pp.rename_variable(...)).Rename a variable (of all eyes or of eyes).
Values, mask layers and the parameters of
scale()move to the new name; so do the limits of an uncertainty band (<eye>_<old>_lowerand_upper). Typical use: move a variable out of the way before another one takes its name. For the channels inaux, seeEyeDataDict.rename.- Parameters:
old (
str) – the variable (e.g.,"pupil")new (
str) – its new name (e.g.,"pupilraw")eyes (
str|list) – only these eyes; default all eyes with the variableoverwrite (
bool) – replace the variable new if it exists (else an error)inplace (bool or None, optional) – if True, make change in-place and return the object; if False, make and return copy before making changes; if None, use the object-level setting (specified in the constructor)
- Return type:
- Returns:
the object with the renamed variable (self or a copy, depending on inplace)
- Raises:
KeyError – if the variable does not exist (for an eye in eyes)
ValueError – if new exists (and not overwrite)
See also
copy_variablekeep the variable and add a copy
Examples
>>> import pypillometry as pp >>> d = pp.get_example_data("rlmw_002_short") >>> d = d.rename_variable("pupil", "pupilraw", inplace=False) >>> d.data.variables ['x', 'y', 'pupilraw']