简体   繁体   English

TypeError: can't pickle _thread.RLock objects in pandas with multiprocessing

[英]TypeError: can't pickle _thread.RLock objects in pandas with multiprocessing

I have a dataframe of 12000 rows.我有一个 12000 行的数据框。 I want to use pandas with multiprocessing and perform mapping on the dataframe.我想将熊猫与多处理一起使用并在数据帧上执行映射。

df =  pd.read_csv(input_file, dtype=str, names=columns)
df_split = np.array_split(df, 4)
# pool = mp.Pool(4)
for df_data in df_split:
    param = [df_data, version, logger]
    with mp.Pool(4) as pool:
        out_df_lst = pool.map(func, param)
out_df = pd.concat(out_df_lst)

All this program is within a Django REST API, when I make a POST request through Postman it throws the error: 'TypeError: can't pickle _thread.RLock objects'.所有这些程序都在 Django REST API 中,当我通过 Postman 发出 POST 请求时,它会抛出错误:'TypeError: can't pickle _thread.RLock objects'。 The program works as intended when I make a request without any multiprocessing.当我在没有任何多处理的情况下发出请求时,该程序按预期工作。

Please help me understand this issue to make the program work with multiprocessing.请帮助我理解这个问题,以使程序与多处理一起工作。

This is the entire Traceback:这是整个 Traceback:

Traceback (most recent call last):
  File "C:\Users\kotamrajua\Anaconda3\envs\ahrqcomenv\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Users\kotamrajua\Anaconda3\envs\ahrqcomenv\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\kotamrajua\methodologies-pyapis\ahrq_comorbidity\ahrq_comorb_app\scripts\process_ahrq.py", line 97, in run_ahrq_process
    out_df_lst = pool.map(run_comorb_mapping, param)
  File "C:\Users\kotamrajua\Anaconda3\envs\ahrqcomenv\lib\multiprocessing\pool.py", line 266, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "C:\Users\kotamrajua\Anaconda3\envs\ahrqcomenv\lib\multiprocessing\pool.py", line 644, in get
    raise self._value
  File "C:\Users\kotamrajua\Anaconda3\envs\ahrqcomenv\lib\multiprocessing\pool.py", line 424, in _handle_tasks
    put(task)
  File "C:\Users\kotamrajua\Anaconda3\envs\ahrqcomenv\lib\multiprocessing\connection.py", line 206, in send
    self._send_bytes(_ForkingPickler.dumps(obj))
  File "C:\Users\kotamrajua\Anaconda3\envs\ahrqcomenv\lib\multiprocessing\reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
TypeError: can't pickle _thread.RLock objects
from pandarallel import pandarallel
pandarallel.initialize()

                  # Include raw=True if the func needs ndarrays.
out_df = df.parallel_apply(func, args=(version, logger), axis=1) 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 multiprocessing / psycopg2 TypeError:无法pickle _thread.RLock对象 - multiprocessing / psycopg2 TypeError: can't pickle _thread.RLock objects 类型错误:无法pickle _thread.RLock 对象 - TypeError: can't pickle _thread.RLock objects TypeError:无法在 python 3 中腌制 _thread.RLock 对象 - TypeError: can't pickle _thread.RLock objects in python 3 Tensflow Keras: TypeError: can't pickle _thread.RLock objects when using multiprocessing - Tensflow Keras: TypeError: can't pickle _thread.RLock objects when using multiprocessing 获取 TypeError:无法pickle _thread.RLock 对象 - Getting TypeError: can't pickle _thread.RLock objects TypeError: can't pickle _thread.RLock objects (Deep Learning) - TypeError: can't pickle _thread.RLock objects ( Deep Learning) “TypeError: can't pickle _thread.RLock objects”,同时使用 pickle 保存 Facebook Prophet 模型 - "TypeError: can't pickle _thread.RLock objects" while saving Facebook Prophet model using pickle _pickle.PicklingError:无法序列化对象:TypeError:无法腌制_thread.RLock对象 - _pickle.PicklingError: Could not serialize object: TypeError: can't pickle _thread.RLock objects Python3不能通过多处理来挑选列表上的_thread.RLock对象 - Python3 can't pickle _thread.RLock objects on list with multiprocessing Keras模型上的递归特征消除(RFE)-TypeError:无法腌制_thread.RLock对象 - Recursive Feature Elimination (RFE) on Keras Model - TypeError: can't pickle _thread.RLock objects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM