I want to iterate over a data frame using itertuples()
, the common way to do this:
for row in df.itertuples():
my_funtion(row) # do something with row
However now I wish to do the loop in parallel using joblib like this (which seems very straightforward to me):
num_cores = multiprocessing.cpu_count()
processed_list = Parallel(n_jobs=num_cores)(delayed(my_function(row) for row in df.itertuples()))
However I got the following error:
File "/home/anaconda3/envs/pytorch/lib/python3.7/site-packages/joblib/parallel.py", line 885, in call iterator = iter(iterable) TypeError: 'function' object is not iterable
Please, any idea what could be the problem?