I am trying to iterate multiple column rows and multiply nth row to n+1 row after that add columns. I tried below code and it's working fine. Is there any other simply way to achieve the subtraction and multiplication part together? import pandas as pd df = pd.DataFrame({'C': ["Spark","PySpark","Python","pandas","Java"], 'F' : [2,4,3,5,4], 'D':[3,4,6,5,5]}) df1 = pd.DataFrame({'C': ["Spark","PySpark","Python","pandas","Java"], 'F': [1,2,1,2,1], 'D':[1,2,2,2,1]}) df = pd.merge(df, df1, on="C") df['F_x-F_y'] = df['F_x'] - df['F_y'] df['D_x-D_y'] = df['D_x'] - df['D_y'] for index, row in df.iterrows(): df['F_mul'] = df['F_x-F_y'].mul(df['F_x-F_y'].shift()) df['D_mul'] = df['D_x-D_y'].mul(df['D_x-D_y'].shift()) df['F+D'] = df['F_mul'] + df['D_mul']  Output -  C F_x D_x F_y D_y F_x-F_y D_x-D_y F_mul D_mul F+D 0 Spark 2 3 1 1 1 2 NaN NaN NaN 1 PySpark 4 4 2 2 2 2 2.0 4.0 6.0 2 Python 3 6 1 2 2 4 4.0 8.0 12.0 3 pandas 5 5 2 2 3 3 6.0 12.0 18.0 4 Java 4 5 1 1 3 4 9.0 12.0 21.0 
First remove iterating by iterrows, then is possible simplify a generalize solution by: cols = ['F','D'] for col in cols: s = df[f'{col}_x'].sub(df[f'{col}_y']) df[f'{col}_mul'] = s.mul(s.shift()) df['+'.join(cols)] = df.filter(like='mul').sum(axis=1, min_count=1) print (df) C F_x D_x F_y D_y F_mul D_mul F+D 0 Spark 2 3 1 1 NaN NaN NaN 1 PySpark 4 4 2 2 2.0 4.0 6.0 2 Python 3 6 1 2 4.0 8.0 12.0 3 pandas 5 5 2 2 6.0 12.0 18.0 4 Java 4 5 1 1 9.0 12.0 21.0  Another idea is processing all columns together - advantage is dont need specify columns for processing: df1 = (df.filter(like='x').rename(columns=lambda x: x.replace('x','mul')) .sub(df.filter(like='y').rename(columns=lambda x: x.replace('y','mul')))) df2 = df1.mul(df1.shift()) df = df.join(df2) df['+'.join(x.replace('_mul','') for x in df2.columns)] = df2.sum(axis=1, min_count=1) print (df) C F_x D_x F_y D_y F_mul D_mul F+D 0 Spark 2 3 1 1 NaN NaN NaN 1 PySpark 4 4 2 2 2.0 4.0 6.0 2 Python 3 6 1 2 4.0 8.0 12.0 3 pandas 5 5 2 2 6.0 12.0 18.0 4 Java 4 5 1 1 9.0 12.0 21.0 