尝试将稀疏 df 保存到 hdf5 时获取 'SparseDtype' 对象没有属性 'itemsize'?

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

我正在尝试将大型稀疏数据帧保存到 hdf5 文件,但出现归因错误:

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')

我收到错误:

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

我为 to_hdf 尝试了不同的组合,但没有成功。我以前从未转换为 hdf5,所以我可能会遗漏一些东西。我在 google 上找不到有关此错误的任何信息,所以我想知道是什么导致了此错误?我能做些什么来解决它?

https://github.com/pandas-dev/pandas/issues/31199 to_hdf 尚不支持稀疏数据类型。

好消息是它是众所周知的,但坏消息是它没有分配给任何人,也没有进行任何修复。