我想讀取先前使用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