我有一个my_file.h5文件,大概包含HDF5格式的数据(PyTables)。我尝试使用pandas读取此文件:

import pandas as pd
store = pd.HDFStore('my_file.h5')

然后我尝试使用store对象:
print store

结果我得到:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.7/pandas/io/pytables.py", line 133, in __repr__
    kind = v._v_attrs.pandas_type
  File "/usr/lib/python2.7/dist-packages/tables/attributeset.py", line 302, in __getattr__
    (name, self._v__nodePath)
AttributeError: Attribute 'pandas_type' does not exist in node: '/data'

有人知道我做错了什么吗?这个问题是不是因为我的*.h5不是我想的那样(不是hdf5格式的数据)?

最佳答案

在您的/usr/lib/pymodules/python2.7/pandas/io/pytables.py中,第133行

kind = v._v_attrs.pandas_type

我明白了
kind = getattr(n._v_attrs,'pandas_type',None)

通过使用pytables.py,如果没有getattr属性,则将pandas_type设置为kind。我猜我的熊猫版
In [7]: import pandas as pd

In [8]: pd.__version__
Out[8]: '0.10.0'

比你的新。如果是这样,那么修复方法是升级None

10-07 19:23
查看更多