skbio.stats.distance.DissimilarityMatrix.rename#

DissimilarityMatrix.rename(mapper, strict=True)[source]#

Rename IDs in the dissimilarity matrix.

Parameters:
mapperdict or callable

A dictionary or function that maps current IDs to new IDs.

strictbool, optional

If True (default), every ID in the matrix must be included in mapper. If False, only the specified IDs will be renamed.

Raises:
ValueError

If mapper does not contain all of the same IDs in the matrix whereas in strict mode.

Examples

>>> from skbio import DistanceMatrix
>>> dm = DistanceMatrix([[0, 1], [1, 0]], ids=['a', 'b'])
>>> dm.rename({'a': 'x', 'b': 'y'})
>>> print(dm.ids)
('x', 'y')