我想读取先前使用PyTables
创建的h5文件。使用带有表格格式和数据列的pytables创建HDF5文件
该文件使用Pandas
读取,并与一些条件,像这样:
pd.read_hdf('myH5file.h5', 'anyTable', where='some_conditions')
从另一个问题,我已被告知,为了对H5文件是“可查询”与read_hdf's where
说法它必须写在table format
,此外,一些列必须声明为data columns
。
我在PyTables文档中找不到任何关于它的信息。
有关PyTable的create_table
方法的文档没有提供任何有关它的信息。
所以,现在,如果我尝试使用类似的东西在我的H5文件createed与PyTables我得到如下:
>>> d = pd.read_hdf('test_file.h5','basic_data', where='operation==1')
C:\Python27\lib\site-packages\pandas\io\pytables.py:3070: IncompatibilityWarning:
where criteria is being ignored as this version [0.0.0] is too old (or
not-defined), read the file in and write it out to a new file to upgrade (with
the copy_to method)
warnings.warn(ws, IncompatibilityWarning)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 323, in read_hdf
return f(store, True)
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 305, in <lambda>
key, auto_close=auto_close, **kwargs)
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 665, in select
return it.get_result()
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 1359, in get_result
results = self.func(self.start, self.stop, where)
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 658, in func
columns=columns, **kwargs)
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 3968, in read
if not self.read_axes(where=where, **kwargs):
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 3196, in read_axes
values = self.selection.select()
File "C:\Python27\lib\site-packages\pandas\io\pytables.py", line 4482, in select
start=self.start, stop=self.stop)
File "C:\Python27\lib\site-packages\tables\table.py", line 1567, in read_where
self._where(condition, condvars, start, stop, step)]
File "C:\Python27\lib\site-packages\tables\table.py", line 1528, in _where
compiled = self._compile_condition(condition, condvars)
File "C:\Python27\lib\site-packages\tables\table.py", line 1366, in _compile_condition
compiled = compile_condition(condition, typemap, indexedcols)
File "C:\Python27\lib\site-packages\tables\conditions.py", line 430, in compile_condition
raise _unsupported_operation_error(nie)
NotImplementedError: unsupported operand types for *eq*: int, bytes
编辑:
回溯提到关于IncompatibilityWarning东西和版本[0.0.0],但是如果我检查我的熊猫和表格的版本,我得到:
>>> import pandas
>>> pandas.__version__
'0.15.2'
>>> import tables
>>> tables.__version__
'3.1.1'
所以,我TOT盟友困惑。
好,您正在使用熊猫读取这个文件,所以文档是[这里](http://pandas.pydata.org/pandas-docs/stable/io的.html#HDF5-pytables)。熊猫可以读取PyTables的“表格”格式。所以不完全清楚你是如何创造的。 – Jeff
杰夫,这个问题不是关于阅读是关于如何使用PyTables创建h5文件,并使表格具有'table'格式并使某些列成为'数据列'以便能够用熊猫读取它们,并且此信息是不在PyTables文档据我所知 – codeKiller
你必须使用熊猫来创建它们:pytables只是一个存储层。请阅读我指出的文档 – Jeff