-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merging AnnData.obs object with Pandas DataFrame may fail #441
Comments
I don't think we'll allow assignment to the |
I think it could be useful for this kind of thing to be easier. Not sure what the right api is for it though. |
How about a new class method df, adata_obs = df.align(adata.obs, join="inner", axis=0)
adata = adata[adata_obs.index, :]
adata.obs = adata.obs.merge(labels, left_index=True, right_index=True) The arguments to tweak Pandas |
How about something more like adata = anndata.merge([adata, {"obs": df, "obsm": {...}}], join="inner", strategy="first") One issue is that this doesn't mutate the This could also lead to adding |
I'm going to close this in favor of #658 where I've fleshed the idea out a bit more, so what would actually be implemented is the focus of the issue |
Description
Given an AnnData object
adata
, it is currently not possible to mergeadata.obs
with a PandasDataFrame
if the resulting index differs from the originaladata.obs_names
.For example (using
anndata=0.7.4
),throws the
ValueError
Is this intended or is it planned to allow merges of this kind in the future? Is there an easier workaround than subsetting both the
DataFrame
andAnnData
prior to merging?The text was updated successfully, but these errors were encountered: