如何在函数上应用多处理逻辑

2024-09-28 03:17:19 发布

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

我有一个应用于数据帧的函数,它需要更多的时间来执行,所以我想尝试在该函数中进行多处理

import multiprocessing
pool = multiprocessing.Pool(multiprocessing.cpu_count())

def some_function_you_want_executed_in_parallel(args):
   pass  # logic goes here

arg_list = []  # put input arguments here

results = pool.map(some_function_you_want_executed_in_parallel, arg_list)





PLAA_Scripts2['ClaimUnitsWithRespite_CA_CUWR'] = PLAA_Scripts2.apply(lambda x :\
    fsScripts_getClaimUnitsWithRespite_Inline1(EndDate,\
    x['BeginDate_SC'],x['EndDate_SC'],x['AuthorizationID_SC'],False),axis=1,result_type='reduce') 

我必须将上述多处理逻辑应用于fsScripts_getClaimUnitsWithRespite_Inline1函数,该函数的值来自数据帧PLAA_Scripts2的列

如何将多处理逻辑应用于此函数


Tags: 数据函数inyouhereparallelfunctionsome

热门问题