加速。九只Pandas

2024-04-25 14:06:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在努力加速下面的代码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

如有任何帮助/建议,将不胜感激。 谢谢


Tags: ofinloopfordbdatebarcurrent

热门问题