다음 코드의 속도를 높이려고합니다. 'db'는 DataFrames 사전입니다. 이 속도를 높일 수있는 방법을 구성하는 더 나은/다른 방법이 있습니까?팬더에서 .ix 속도 향상
%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
어떤 도움/제안은 감사하겠습니다
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.)
다음은 결과입니다. 감사합니다.
['.apply'] (http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.apply.html#pandas.DataFrame.apply)를 사용하여 'axis = 1 ' –