matrix.Matrix.rename_criteria

Matrix.rename_criteria(criterion: Optional[str] = None, name: Optional[str] = None, **old_to_new_names)

Update the name of a given criterion

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

  • name (Optional[str]) – The new criterion 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()
>>> m.add_criteria('color', 'taste', weights=(4, 7))
>>> m.rename_criteria('color', 'colour')
>>> m
|        |   colour |   taste |
|:-------|---------:|--------:|
| Weight |        4 |       7 |
>>> m = matrix.Matrix()
>>> m.add_criteria('color', 'taste', weights=(4, 7))
>>> m.rename_criteria(color='colour', taste='flavour')
>>> m
|        |   colour |   flavour |
|:-------|---------:|----------:|
| Weight |        4 |         7 |