私は、hdf
テーブルからソートされたレコードを取得する方法を探しています。ここでのpython MWEは次のとおりです。hdfテーブルからソートされたレコードを取得する方法
import tables
import numpy as np
class Measurement(tables.IsDescription):
time = tables.Float64Col()
value = tables.Float64Col()
h5 = tables.open_file('test.hdf', 'w')
h5.create_table('/', 'test', Measurement)
table = h5.root.test
data = np.array([(0, 6), (5, 1), (1, 8)], dtype=[('time', '<f8'), ('value', '<f8')])
table.append(data)
table.cols.time.createCSIndex()
今、私はtime
によって並べ替えられ、time > 0
ですべてのレコードを取得したいと思います。私が行う場合:
table.read_where('time > 0')
を、それが取得されます。time
によってソートされていない
array([(5.0, 1.0), (1.0, 8.0)], dtype=[('time', '<f8'), ('value', '<f8')])
を。 read_sorted
を使用しようとすると、サブセットの代わりにテーブル全体が得られます(read_sorted
の条件引数はありません)。
よくあることは何ですか?私のテーブルがデータベースにソートされて保存されていることを確認する必要がありますか?または、私はread_where
の後に検索されたセットを自分自身で並べ替えるべきですか?