def calc_dist(x):
    ret = pd.DataFrame([[grp, df.loc[c[0]].ser_no, df.loc[c[1]].ser_no,
        vincenty(df.loc[c[0], x], df.loc[c[1], x])] for grp, lst in list(df.
        groupby('co_nm').groups.items()) for c in combinations(lst, 2)],
        columns=['co_nm', 'machineA', 'machineB', 'distance'])
print(ret)
return ret
if __name__ == '__main__':
    pool = mp.Pool(processes=mp.cpu_count() - 1)
pool.map(calc_dist, ['lat', 'lon'])
pool.close()
pool.join()
Python: использование многопроцессорности в кадре данных pandas