我想通过convert\u dtypes转换df的数据类型,但如果我想通过HDFStore存储它,我会得到以下结果:AttributeError:“IntegerArray”对象没有属性“size”
df = pd.DataFrame()
df["test"] = [0,1,2,3]
df["test1"] = [0,1,2,3.5]
df = dfdf.convert_dtypes()
store=pd.HDFStore(r"C:\Users\User\Desktop\test.h5")
store["test"] = df
store.close()
我也经历过同样的问题。IntegerArray具有可以表示NAN的属性(类似于float64),这在pandas中的正常numpy int数据类型中是不可能的。但是,这会导致写入HDF时此数据类型失败。请参见此处(https://github.com/pandas-dev/pandas/issues/26144)。如果您的列中没有任何NAN,以下是一个简单而快速的解决方案:
相关问题 更多 >
编程相关推荐