matrix.Matrix.rename_choices

Matrix.rename_choices(choice: Optional[str] = None, name: Optional[str] = None, **old_to_new_names)

Update the name of a given choice

Parameters
  • choice (Optional[str]) – The old choice name.

  • name (Optional[str]) – The new choice name.

Keyword Arguments

**old_to_new_names (str) – The mapping of old names to new names.

Raises

TypeError – If neither (criterion and name) nor old_to_new_names is given.

Examples

>>> import matrix
>>> m = matrix.Matrix('apple', 'orange')
>>> m.rename_choices('apple', 'pear')
>>> m
|:-------|
| Weight |
| pear   |
| orange |
>>> m = matrix.Matrix('apple', 'orange')
>>> m.rename_choices(apple='pear', orange='lemon')
>>> m
|:-------|
| Weight |
| pear   |
| lemon  |