Answers for "pandas parallelize for loop"

0

pandas parallelize for loop

import multiprocessing as mp
pool = mp.Pool(processes=mp.cpu_count())

def func( arg ):
    idx,row = arg
	# Edit df
    return row

new_rows = pool.map( func, [(idx,row) for idx,row in data_all.iterrows()])
data_all_new = pd.concat( new_rows )
Posted by: Guest on August-31-2021

Python Answers by Framework

Browse Popular Code Answers by Language