我正在尝试将信息存储在 pytables 子类中。我有我的类记录和子类数据。对于每行记录,数据将有很多行。我不想使用带有 row.append() 的循环,因为它看起来会非常慢。我可以只创建一个数组并将其放入 Data.v 列吗?如何?
import tables as tbs
import numpy as np
class Record(tbs.IsDescription):
filename = tbs.StringCol(255)
timestamp = tbs.Time32Col()
class Data(tbs.IsDescription):
v = tbs.Int32Col(dflt=None)
...
row = table.row
for each in importdata:
row['filename'] = each['filename']
row['timestamp'] = each['timestamp']
# ???? I want to do something like this
row.Data = tbs.Array('v', each['v'], shape=np.shape(each['v']))
row.append()