TypeError:read_hdf()只需2个参数(给定1个)

时间:2014-11-24 04:35:28

标签: python pandas hdf5 pytables

如果密钥未知,如何使用pandas.read_hdf打开HDF5文件?

from pandas.io.pytables import read_hdf
read_hdf(path_or_buf, key)
pandas.__version__ == '0.14.1'

此处的关键参数未知。感谢

2 个答案:

答案 0 :(得分:3)

在我能够使用online docs烹饪示例之前从未使用过hdf文件:

In [59]:
# create a temp df and store it
df_tl = pd.DataFrame(dict(A=list(range(5)), B=list(range(5))))
df_tl.to_hdf('store_tl.h5','table',append=True)
In [60]:
# we can simply read it again and the keys are displayed
store = pd.HDFStore('store_tl.h5')
# keys will be displayed in the output
store
Out[60]:
<class 'pandas.io.pytables.HDFStore'>
File path: store_tl.h5
/table            frame_table  (typ->appendable,nrows->5,ncols->2,indexers->[index])
In [61]:
# read it back in again
t = pd.read_hdf('store_tl.h5', 'table')
t
Out[61]:
   A  B
0  0  0
1  1  1
2  2  2
3  3  3
4  4  4

所以基本上只是使用HDFStore加载它并传递路径然后只显示对象将在输出中打印键。

答案 1 :(得分:2)

或者您可以Error:(42, 23) java: generics are not supported in -source 1.3 (use -source 5 or higher to enable generics)

https://github.com/pydata/pandas/blob/master/pandas/io/pytables.py#L492