提高jupyter笔记本中python代码的处理速度

问题描述 投票:-3回答:1

我有一个Python脚本操作300万行的数据集,CPU使用率仅为25%,那么如何通过在CPU中使用多个内核或完全利用CPU来提高处理速度?

多处理和进程池所需的输入。

python python-3.x jupyter-notebook anaconda
1个回答
0
投票
import multiprocessing
pool = multiprocessing.Pool(multiprocessing.cpu_count())

def some_function_you_want_executed_in_parallel(args):
   pass  # logic goes here

arg_list = []  # put input arguments here

results = pool.map(some_function_you_want_executed_in_parallel, arg_list)
© www.soinside.com 2019 - 2024. All rights reserved.