我正在努力加速下面的代码db'是数据帧的字典。有没有更好的/不同的方法来组织事情来加速这一进程?你知道吗
for date in dates: # 3,800 days
for instrument in instruments: # 100 instruments
s = instrument.ticker
current_bar = db[s].ix[date]
# (current_bar.xxx then gets used for difference calculations.)
结果如下:
%timeit speedTest()
1 loops, best of 3: 1min per loop
这适用于每个单独的呼叫:
%timeit current_bar = db[s].ix[date]
10000 loops, best of 3: 154 µs per loop
如有任何帮助/建议,将不胜感激。 谢谢
我认为数据帧的dict不是一个好主意。尝试在一个堆栈中垂直构造所有数据帧,并使用键作为索引/多级索引。你知道吗
相关问题 更多 >
编程相关推荐