anndata.AnnData.rename_categories

AnnData.rename_categories(key, categories)

Rename categories of annotation key in obs, var, and uns.

Only supports passing a list/array-like categories argument.

Besides calling self.obs[key].cat.categories = categories – similar for var - this also renames categories in unstructured annotation that uses the categorical annotation key.

Parameters
key : str

Key for observations or variables annotation.

categories : Sequence[Any]

New categories, the same number as the old categories.