spateo-release
spateo-release copied to clipboard
TypeError when creating AnnData object from Pandas DataFrame
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
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