import pandas as pd
from pandas import DataFrame
import tables as pytb
with pytb.open_file('debug_counts.h5', mode='r') as h5file:
table = h5file.get_node('/tbl_main')
print("number of rows in table =", table.nrows)
i = 0
j = 0
for row in table:
j += 1
if row['symbol'] == b"foo":
i += 1
print("table all records count =", j)
print("table foo records count =", i)
df = pd.DataFrame.from_records(table.read_where('(symbol == b"foo")'))
print("dataframe size =", df.size)
i = 0
for index, row in df.iterrows():
i += 1
print("dataframe records count =", i)
i = 0
for record in table.where('(symbol == b"foo")'):
i += 1
print("table.where records count =", i)
h5file.close()
Выход:
runfile('G:/$HDF5/debug_counts.py', wdir='G:/$HDF5')
number of rows in table = 2826254
table all records count = 2826254
table foo records count = 37920
dataframe size = 985920
dataframe records count = 37920
table.where records count = 37920
Большие цифры верны. Номера 37920 неверны или, по крайней мере, не то, что я хочу. Как получить выходной сигнал, который я ищу (985920, а не 37920), и откуда берется 37920?