Skip to content
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

Include metadata when converting to Pandas DataFrame #1399

Open
WeilerP opened this issue Mar 6, 2024 · 4 comments · May be fixed by #1400
Open

Include metadata when converting to Pandas DataFrame #1399

WeilerP opened this issue Mar 6, 2024 · 4 comments · May be fixed by #1400

Comments

@WeilerP
Copy link
Contributor

WeilerP commented Mar 6, 2024

Please describe your wishes and possible alternatives to achieve the desired result.

Description

AnnData.to_df only converts data from .X or a layer to a DataFrame. It'd be great to also add metadata column from AnnData.obs. This feature would make it easier to work with Pandas groupby on the generated DataFrame, for example.

@ivirshup
Copy link
Member

ivirshup commented Mar 6, 2024

To me, this kind of use case is covered by sc.get.obs_df. Is there some reason that doesn't do what you need?

@WeilerP WeilerP linked a pull request Mar 6, 2024 that will close this issue
@ivirshup
Copy link
Member

ivirshup commented Mar 6, 2024

Alternatively, adata.to_df().join(adata.obs)

@WeilerP
Copy link
Contributor Author

WeilerP commented Mar 6, 2024

To me, this kind of use case is covered by sc.get.obs_df. Is there some reason that doesn't do what you need?

It requires Scanpy instead of using AnnData directly. And yes, you can always merge the relevant columns; it'd just be easier via an argument.

@ivirshup
Copy link
Member

ivirshup commented Mar 6, 2024

It requires Scanpy instead of using AnnData directly.

Just to establish an alternative: if sc.get.obs_df instead lived in anndata, that would be sufficient?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants