Linked Questions

Popular Questions

How to use multiprocessing in simple/ nested for loops?

Asked by At

I am working on a code that reads stuff from once CSV file and compare some of its columns to some of its other columns and after doing so edits one column in the CSV file using dataframes and creating a new file in the end. Currently it takes a lot of time and i want to use Multiprocessing to reduce the time. How can I do forward with this?

df2 = pd.read_csv('initial.csv')
df = pd.read_csv('initial.csv')
for (index, row) in df2.iterrows():
    counter = 0
    counterStarter = False 
    mF = row['columnB']
    mI = row['columnB']
    for (index2, row2) in df.iterrows():
        if counterStarter == True:
            counter += 1
        if mI == row2['columnC'] and mF == row2['columnA']:
            counterStarter = True
            newM = str(row['columnD']) + str(patchRow['columnD'])
  [index2, 'columnD'] = newM

        if counter > 500:
            counter = 0
            counterStarter = False


Related Questions