问题记录——pd.read_hdf throws 'cannot set WRITABLE flag to True of this array'

  • 时间:
  • 浏览:
  • 来源:互联网

问题记录——pd.read_hdf throws 'cannot set WRITABLE flag to True of this array'

    • 解决办法:降级numpy

可以使用如下写入h5文件

df.to_hdf('../testA.h5', 'df')

但是无法读取h5文件

a = pd.read_hdf("../testA.h5","df")
a

报错:

~/.local/lib/python3.6/site-packages/pandas/io/pytables.py in read_array(self, key, start, stop) 2487 2488 if isinstance(node, tables.VLArray): -> 2489 ret = node[0][start:stop] 2490 else: 2491 dtype = getattr(attrs, 'value_type', None)

~/.local/lib/python3.6/site-packages/tables/vlarray.py in getitem(self, key)

~/.local/lib/python3.6/site-packages/tables/vlarray.py in read(self, start, stop, step)

tables/hdf5extension.pyx in tables.hdf5extension.VLArray._read_array()

ValueError: cannot set WRITEABLE flag to True of this array

解决办法:降级numpy

降级前numpy.version 1.18.0

pip install numpy==1.15

问题解决。

本文链接http://www.hatan.cn/news/show-6049.html