from multiprocessing import Poolclass A: def __init__(self, n): self.n = n def __foo(self, i): return i + 1 def bar(self): l = list(map(self.__foo, range(self.n))) print(len(l)) def baz(self): pool = Pool(2) l = list(pool.map(self.__foo, range(self.n))) print(len(l))a = A(3)a.bar()a.baz()這是簡短的輸出:3AttributeError: 'A' object has no attribute '__foo'我想用它Pool來處理一個大的dataframe,但Pool.map不起作用——如何處理它?
添加回答
舉報
0/150
提交
取消