我已经构建了一个pytable表,并使用附件填充了它,如下所示:
h5file = open_file("FGBS.h5", mode = "a")
group = h5file.create_group("/", 'hybrid')
table = h5file.create_table(group, 'z4', Hybrid ,filters= tb.Filters(5, "blosc"))使用:
class Hybrid(IsDescription):
dateTime = Time32Col()
price = Float64Col()
quantity = Float64Col()
bidPrc = Float64Col()
bidSize = Float64Col()
askPrc = Float64Col()
askSize = Float64Col()并附在表上:
if 0 in dictInstrumentsData[message.symbol].bidPrice and 0 in dictInstrumentsData[message.symbol].askPrice:
hybrid = table.row
hybrid["dateTime"] = message.timestamp * 0.001
hybrid["price"] = message.price
hybrid["quantity"] = message.size
hybrid["bidPrc"] = dictInstrumentsData[message.symbol].bidPrice[0]
hybrid["bidSize"] = dictInstrumentsData[message.symbol].bidSize[0]
hybrid["askPrc"] = dictInstrumentsData[message.symbol].askPrice[0]
hybrid["askSize"] = dictInstrumentsData[message.symbol].askSize[0]
hybrid.append()现在我正试着把它读回一只熊猫的数据,就像这样:
a = tb.open_file("FGBS.h5")
table = a.root.quote.z4
c = pd.DataFrame.from_records(table)但是当我看c的时候,我得到的只是:
0 \
0 /hybrid/z4.row (Row), pointing to row #164411
1 \
0 /hybrid/z4.row (Row), pointing to row #164411
2 \
0 /hybrid/z4.row (Row), pointing to row #164411
3 \
0 /hybrid/z4.row (Row), pointing to row #164411
4 \
0 /hybrid/z4.row (Row), pointing to row #164411
5 \
0 /hybrid/z4.row (Row), pointing to row #164411
6 \
0 /hybrid/z4.row (Row), pointing to row #164411
7 \
0 /hybrid/z4.row (Row), pointing to row #164411
8 \
0 /hybrid/z4.row (Row), pointing to row #164411
9 \
0 /hybrid/z4.row (Row), pointing to row #164411
... \
0 ...
164401 \
0 /hybrid/z4.row (Row), pointing to row #164411
164402 \
0 /hybrid/z4.row (Row), pointing to row #164411
164403 \
0 /hybrid/z4.row (Row), pointing to row #164411
164404 \
0 /hybrid/z4.row (Row), pointing to row #164411
164405 \
0 /hybrid/z4.row (Row), pointing to row #164411
164406 \
0 /hybrid/z4.row (Row), pointing to row #164411
164407 \
0 /hybrid/z4.row (Row), pointing to row #164411
164408 \
0 /hybrid/z4.row (Row), pointing to row #164411
164409 \
0 /hybrid/z4.row (Row), pointing to row #164411
164410
0 /hybrid/z4.row (Row), pointing to row #164411
[1 rows x 164411 columns]不是基于每个附加的混合列和行的数据文件。有人能帮我看看我做错了什么吗?
发布于 2015-01-13 10:06:38
您需要从表中显式读取数据。Table.read将提取整个表,哪里允许您应用一个条件语句来筛选返回的数据。
a = tb.open_file("FGBS.h5")
table = a.root.quote.z4
c = pd.DataFrame.from_records(table.read())https://stackoverflow.com/questions/27918990
复制相似问题