我有一个使用 pytables 创建的数据集,我正在尝试将其导入 pandas 数据框。我无法where
对步骤应用过滤器read_hdf
。我在熊猫'0.12.0'
我的示例 pytables 数据:
import tables
import pandas as pd
import numpy as np
class BranchFlow(tables.IsDescription):
branch = tables.StringCol(itemsize=25, dflt=' ')
flow = tables.Float32Col(dflt=0)
filters = tables.Filters(complevel=8)
h5 = tables.openFile('foo.h5', 'w')
tbl = h5.createTable('/', 'BranchFlows', BranchFlow,
'Branch Flows', filters=filters, expectedrows=50e6)
for i in range(25):
element = tbl.row
element['branch'] = str(i)
element['flow'] = np.random.randn()
element.append()
tbl.flush()
h5.close()
我可以将其导入数据框:
store = pd.HDFStore('foo.h5')
print store
print pd.read_hdf('foo.h5', 'BranchFlows').head()
这表明:
In [10]: print store
<class 'pandas.io.pytables.HDFStore'>
File path: foo.h5
/BranchFlows frame_table [0.0.0] (typ->generic,nrows->25,ncols->2,indexers->[index],dc->[branch,flow])
In [11]: print pd.read_hdf('foo.h5', 'BranchFlows').head()
branch flow
0 0 -0.928300
1 1 -0.256454
2 2 -0.945901
3 3 1.090994
4 4 0.350750
但我无法让过滤器在流柱上工作:
pd.read_hdf('foo.h5', 'BranchFlows', where=['flow>0.5'])
<snip traceback>
TypeError: passing a filterable condition to a non-table indexer [field->flow,op->>,value->[0.5]]