spateo-release icon indicating copy to clipboard operation
spateo-release copied to clipboard

TypeError when creating AnnData object from Pandas DataFrame

Open WeipengMO opened this issue 5 months ago • 1 comments

https://github.com/aristoteleo/spateo-release/blob/22220c57f8d501663be23c8f948dd310b505ca3d/spateo/svg/utils.py#L43

Description:

When trying to create an AnnData object from a Pandas DataFrame using a = AnnData(df2), I encountered a TypeError:

TypeError: Setting a MultiIndex dtype to anything other than object is not supported

image

Workaround:

To fix this issue, I modified the code to create the AnnData object using the values attribute of the DataFrame and a new Pandas DataFrame with the original column names as the index:

a = AnnData(df2.values, var=pd.DataFrame(index=df2.columns))

Best, Weipeng

WeipengMO avatar Sep 10 '24 05:09 WeipengMO