私はPyTablesを初めて使用し、エージェントベースのモデリングシミュレーションから生成され、HDF5に保存されたデータを処理するために使用することを検討しています. 私は 39 MB のテスト ファイルを使って作業していますが、何かおかしいと感じています。テーブルのレイアウトは次のとおりです。
/example/agt_coords (Table(2000000,)) ''
description := {
"agent": Int32Col(shape=(), dflt=0, pos=0),
"x": Float64Col(shape=(), dflt=0.0, pos=1),
"y": Float64Col(shape=(), dflt=0.0, pos=2)}
byteorder := 'little'
chunkshape := (20000,)
Pythonでアクセスする方法は次のとおりです。
from tables import *
>>> h5file = openFile("alternate_hose_test.h5", "a")
h5file.root.example.agt_coords
/example/agt_coords (Table(2000000,)) ''
description := {
"agent": Int32Col(shape=(), dflt=0, pos=0),
"x": Float64Col(shape=(), dflt=0.0, pos=1),
"y": Float64Col(shape=(), dflt=0.0, pos=2)}
byteorder := 'little'
chunkshape := (20000,)
>>> coords = h5file.root.example.agt_coords
ここで、物事が奇妙になります。
[x for x in coords[1:100] if x['agent'] == 1]
[(1, 25.0, 78.0), (1, 25.0, 78.0)]
>>> [x for x in coords if x['agent'] == 1]
[(1000000, 25.0, 78.0), (1000000, 25.0, 78.0)]
>>> [x for x in coords.iterrows() if x['agent'] == 1]
[(1000000, 25.0, 78.0), (1000000, 25.0, 78.0)]
>>> [x['agent'] for x in coords[1:100] if x['agent'] == 1]
[1, 1]
>>> [x['agent'] for x in coords if x['agent'] == 1]
[1, 1]
テーブル全体を反復処理すると値が台無しになる理由がわかりませんが、行セット全体の小さなサブセットを取得するとわかりません。これはライブラリの使用方法に誤りがあると確信しているため、この問題に関するヘルプは非常に高く評価されます。