【问题标题】:Getting 'SparseDtype' object has no attribute 'itemsize' when trying to save sparse df to hdf5?尝试将稀疏df保存到hdf5时,获取'SparseDtype'对象没有属性'itemsize'?
【发布时间】:2021-04-04 08:32:32
【问题描述】:

我正在尝试将大型稀疏数据帧保存到 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,所以我可能会遗漏一些东西。我在谷歌上找不到关于这个错误的任何信息,所以我想知道是什么导致了这个错误?我能做些什么来解决它?

【问题讨论】:

    标签: python pandas hdfs


    【解决方案1】:

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

    好消息是它是已知的,但坏消息是它没有分配给任何人,也没有修复。

    【讨论】:

      猜你喜欢
      • 2020-07-09
      • 1970-01-01
      • 1970-01-01
      • 2017-09-09
      • 2016-12-28
      • 2017-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多