尝试将稀疏df保存到hdf5时,获取"SparseDtype"对象没有属性"itemsize"吗? [英] Getting 'SparseDtype' object has no attribute 'itemsize' when trying to save sparse df to hdf5?

查看:125
本文介绍了尝试将稀疏df保存到hdf5时,获取"SparseDtype"对象没有属性"itemsize"吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我收到错误消息:

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

我为to_hdf尝试了不同的组合,但没有成功.我以前从未转换过hdf5,所以我可能会丢失一些东西.我在Google上找不到关于此错误的任何信息,所以我想知道是什么导致了此错误?该如何解决?

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?

推荐答案

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

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.

这篇关于尝试将稀疏df保存到hdf5时,获取"SparseDtype"对象没有属性"itemsize"吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆