我有一个交易者交易数据集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