Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Joblib and getting "cannot unpack non-iterable function object"

I am new to multiprocessing. The following code properly illustrates what I am trying to do:

import pandas as pd
import multiprocessing
from joblib import Parallel, delayed

one = [True, False]
one_bla = pd.Series(one)
one_names = pd.Series(['Mr. Pea', 'Mrs. Pea'])

one_names = list(zip(one_names, one_names.index))

two = {}

def q():
    for k, m in one_bla.items():
        if one_bla.iloc[i] == True:
            two[i] = v

num_cores = multiprocessing.cpu_count()
results = Parallel(n_jobs=num_cores)(delayed(q) for i, v in one_names)

It's throwing me a TypeError: cannot unpack non-iterable function object. Could someone please see where I am making the mistake?

like image 702
user106742 Avatar asked Feb 22 '26 17:02

user106742


1 Answers

the problem is the missing paranthesis after delayed(q) command. Try this;

results = Parallel(n_jobs=num_cores)(delayed(q)() for i, v in one_names)
like image 56
Alper Aydın Avatar answered Feb 25 '26 09:02

Alper Aydın



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!