#import pakage
import pandas as pd
import multiprocessing
#指定主機有多少CPU,並把df 平均分配size
num_processes = multiprocessing.cpu_count()
chunk_size = int(df.shape[0]/num_processes)
#將df 拆解成 num_processes 個 chunk 的df list
chunks = [df.ix[df.index[i:i + chunk_size]] for i in range(0, df.shape[0], chunk_size)]
#定義 function
def myfunc(d):
return d * d
pool = multiprocessing.Pool(processes=num_processes)
result = pool.map(myfunc, chunks)