anndata.AnnData.var_names_make_unique

AnnData.var_names_make_unique(join='-')

Makes the index unique by appending ‘1’, ‘2’, etc.

The first occurance of a non-unique value is ignored.

Parameters
join : strstr (default: '-')

The connecting string between name and integer.

Examples

>>> from anndata import AnnData
>>> adata1 = AnnData(np.ones((3, 2)), dict(obs_names=['a', 'b', 'c']))
>>> adata2 = AnnData(np.zeros((3, 2)), dict(obs_names=['d', 'b', 'b']))
>>> adata = adata1.concatenate(adata2)
>>> adata.obs_names
Index(['a', 'b', 'c', 'd', 'b', 'b'], dtype='object')
>>> adata.obs_names_make_unique()
>>> adata.obs_names
Index(['a', 'b', 'c', 'd', 'b-1', 'b-2'], dtype='object')