Getting 'SparseDtype' object has no attribute 'itemsize' when trying to save sparse df to hdf5?

穿精又带淫゛_ 提交于 2021-01-28 11:21:02

问题


I'm trying to save a large sparse dataframe to a hdf5 file but I'm getting a attribution error:

one_hot = pd.get_dummies(my_DF, columns=['cat'], sparse=True)
one_hot.to_hdf('/content/data.h5', 'table', mode='w', append=True, complevel=9, complib='bzip2')

I get error:

AttributeError: 'SparseDtype' object has no attribute 'itemsize'

I have tried different combo's for to_hdf but no success. I have never converted to hdf5 before so I might be missing something. I couldn't find anything about this error on google so I'm wonder what is causing this error? and what can I do to fix it?


回答1:


https://github.com/pandas-dev/pandas/issues/31199 to_hdf does not support sparse data types as yet.

The good news is it's known but the bad news is it is not assigned to anyone and no fixes have been put in.



来源:https://stackoverflow.com/questions/65462891/getting-sparsedtype-object-has-no-attribute-itemsize-when-trying-to-save-spa

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!