Open JWatter opened 6 months ago
Could you share your use case for this?
To me, storing a pandas Series is basically the same thing as storing a 1d xarray DataArray. I want to support storing xarray object, and I don't want to have two ways to store the same thing.
Would making this a single column dataframe on your end work here?
Thanks for the quick response! I am gonna argue a bit for the pandas series :)
My immediate use case is serializing a mapping between coarse and fine categories which are also columns of .obsm dataframes. A pandas series is the natural object to use for this.
In principle, using a single column dataframe would work, as would using a plain dictionary. But both would be hacky. The cleaner way is using a pandas series. As far as I know pandas is the de facto standard for storing labeled 1d and 2d arrays. The labeled 2d arrays are already supported as pandas dataframe.
I do understand that it is somewhat redundant to have two ways to store the same thing. Then again, if you support xarray objects, then you introduce a second way of storing 2d labeled arrays as pandas dataframes are already supported, right?
Except for serialization a pandas series in .uns works just fine. One could restrict the types to write in .uns, or construct xarrays whenever pandas series or dataframes (or python dicts) are written into .uns. Personally, I would prefer the flexibility and symmetry in the support of pandas dataframes and pandas series.
.... Just some thoughts, what do you think?
Good to look back once xarray support lands
Please make sure these conditions are met
Report
Hi all,
anndata objects dont serialize as h5ad if they contain a pandas series. This is related to some comments in #797.
Code:
Traceback:
Versions