2
팬더 데이터 프레임으로 가져 오려고하는 파이 테이블로 만든 데이터 세트가 있습니다. read_hdf
단계에 where
필터를 적용 할 수 없습니다. 나는 dataframe에 잘 가져올 수 있습니다팬더 가져 오기에서 파이 테이블 테이블 가져 오기
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
나는 팬더 '0.12.0의'에
내 샘플 pytables 데이터를 해요
하지만 흐름 열에 작동하도록 필터를 가져올 수 없습니다.
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]]
내가 왜 팬더 데이터 프레임을 만들지 않았는지 기억이 안납니다. 지금 당장 numpy는 "ValueError : 배열이 너무 큽니다."라고 말하면서 실제 데이터 세트를 읽으려고하지만 또 다른 문제입니다. – chip
이 작업을 부분적으로 수행 할 수 있습니다 (''append = True''를 패스). 그리고 부분 프레임을 전달하고 테이블을 빌드 할 수 있습니다. [here for more] (http://pandas.pydata.org/pandas-docs/ dev/cookbook.html # hdfstore) – Jeff