anndata.AnnData.rename_categories

AnnData.rename_categories(key, categories)

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

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