I can see how to remove columns from anndata ie
keep = ['a','b','c']
adata = adata [:, keep]
How does one remove rows from anndata.obs
and anndata.x
?
for example remove adata.obs[Region='reg012']
Dataframe adata.obs
CodePudding user response:
If you want to remove row if Region
contians reg012
then..
Assuming Data Frame = adata.obs
adata.obs= adata.obs[~adata.obs.Region.str.contains("reg012")]
CodePudding user response:
You can use drop
based on condition assuming dataframe is adata
:
adata = adata.drop(adata[adata['Region']=='reg012'].index)
Or:
adata = adata.drop(adata.loc[adata['Region']=='reg012'].index)