No unique function for adata.obs

I am using

scanpy

(and

scvi

) for my scRNAseq data analysis I added sample names under adata.obs (adata from different samples are concatenated). I would like to get unique name of every sample using the following command:

adata.obs.sample.unique().tolist()

but getting error and error message is “sample does not have unique function”. when I checked the functions of sample, I noticed that sample does not have any function. do you maybe know what the problem is?

Try this:
sample_list = unique(adata.obs.sample)
I think the issue is that the anndata object itself doesn’t have the unique function, but calling adata.obs.sample first gives you a list to then manipulate.
I hope this helps!