pandas pd.read_hdf 抛出“无法将此数组的 WRITABLE 标志设置为 True”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/54210073/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pd.read_hdf throws 'cannot set WRITABLE flag to True of this array'
提问by Landmaster
When running
跑步时
pd.read_hdf('myfile.h5')
pd.read_hdf('myfile.h5')
I get the following traceback error:
我收到以下回溯错误:
[[...some longer traceback]]
~/.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
[[...一些更长的追溯]]
~/.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)
getitem 中的 ~/.local/lib/python3.6/site-packages/tables/ vlarray.py(self, key)
~/.local/lib/python3.6/site-packages/tables/vlarray.py in read(self, start, stop, step)
表/hdf5extension.pyx 在tables.hdf5extension.VLArray._read_array()
ValueError: 无法将此数组的 WRITEABLE 标志设置为 True
No clue what's going on. I've tried reinstalling tables
, pandas
everything basically, but doesn't want to read it.
不知道发生了什么。我试过重新安装tables
,pandas
基本上所有的东西,但不想读它。
采纳答案by Eddie Bell
Are you using numpy 1.16? It is incompatible with the latest release of pytables (see https://github.com/PyTables/PyTables/blob/v3.4.4/tables/hdf5extension.pyx#L2155) but the pytables team have not yet released a fixed version: https://github.com/PyTables/PyTables/issues/719
你在使用 numpy 1.16 吗?它与最新版本的 pytables 不兼容(参见https://github.com/PyTables/PyTables/blob/v3.4.4/tables/hdf5extension.pyx#L2155)但 pytables 团队尚未发布固定版本:https ://github.com/PyTables/PyTables/issues/719
The only way I found to fix this is to downgrade numpy.
我发现解决此问题的唯一方法是降级 numpy。
回答by rkellerm
Upgrading PyTables to version > 3.5.1 should solve this.
将 PyTables 升级到版本 > 3.5.1 应该可以解决这个问题。
pip install --upgrade tables
回答by Nick Mortimer
It seems that time-date
strings were causing the problem and when I converted these from text to numpy (pd.to_datetime())
and stored the table and the problem went away so perhaps it has something to do with text data?
似乎是time-date
字符串导致了问题,当我将它们从文本转换为 numpy(pd.to_datetime())
并存储表时,问题就消失了,所以也许它与文本数据有关?