我有一個交易者交易數據集df
。 我有環路2級如下:Python:如何在python中運行嵌套並行進程?
smartTrader =[]
for asset in range(len(Assets)):
df = df[df['Assets'] == asset]
# I have some more calculations here
for trader in range(len(df['TraderID'])):
# I have some calculations here, If trader is successful, I add his ID
# to the list as follows
smartTrader.append(df['TraderID'][trader])
# some more calculations here which are related to the first for loop.
我想parallelise每項資產的計算中Assets
,我也想parallelise計算每個交易者的所有資產。所有這些計算完成後,我想根據smartTrader
列表進行附加分析。
這是我第一次嘗試並行處理,請耐心等待,謝謝你的幫助。
試試['multiprocessing.Pool'(HTTPS:/ /docs.python.org/2/library/multiprocessing.html#using-a-pool-of-workers)。 – refi64
我不確定如何在嵌套for循環時調用此函數,請問您可以提供一個小例子嗎? – roland