我试图使用where关键字参数指定的条件,使用pd.HDFStore.select
方法加载存储在HDFStore中的数据帧的子集
由于内存错误,加载整个数据帧并随后使用df.query
失败
存储的数据帧(称为shotsTof
)具有以下结构:
0 1 2 3 ....
pulseId shotNum
72304631 0 -7 -12 -14 -23
2 -2 -5 1 10
4 -4 -1 0 -1
⋮
72304632 0 -5 -10 -9 -8
2 -29 -25 -12 1
4 -7 -6 0 0
⋮
我尝试过这样过滤,其中group.index
是一个与shotsTof具有相同结构的多索引:
store.select('shotsTof', where='index in group.index')
作为:
store.select('shotsTof', where='(pulseId, shotsNum) in group.index')
但是这两种方法都失败了TypeError: float() argument must be a string or a number, not 'tuple'
我还尝试像这样“展平”多索引(以便将索引(72304631, 4)
映射到7230463104
):
idx = group.index.get_level_values(0) * 100 + group.index.get_level_values(1)
shotsTof = store.select('shotsTof', where='(pulseId*100 + shotNum) in idx')
但是我得到了NotImplementedError: unsupported operand types for *and*: bool, long
有谁能帮我理解这个错误,或者提出一个更好的方法来实现我的目标
谢谢
目前没有回答
相关问题 更多 >
编程相关推荐