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

Viewed 246

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 Answers
Related