从apply_async获取结果

时间:2019-07-25 22:25:54

标签: python split multiprocessing

我正在尝试使用块和多重处理从csv文件导入和处理数据。但是,当我想从函数列表中获取结果时,它似乎不起作用。我尝试使用get方法和call_back方法都不适合我。

def import_data(path):
        pixel = []
        label = []
        pool = mp.Pool(5)
        funclist = []
        raw_data = pd.read_csv(path, chunksize = 5000)
        for i, chunk in enumerate(raw_data):
            f = pool.apply_async(split, chunk.iloc[:,1])
            print(i) # check if enter iteration
            funclist.append(f)
            label.append(chunk.iloc[:0])  
        for f in funclist:
            pixel.append(f.get()) 
            print("get result") # check if get result(seems not)
        pixel = pd.concat(pixel)
        label = pd.concat(label)
    return label, pixel
def split(x):
    return x.str.split(" ", expand = True)

0 个答案:

没有答案