I modified my code, it works, but I need the output by group.
df_pct=df.groupby(['col1']).pct_change().sum() The above line of code does only giving the pct_change sum by column (but I want to by column & by group). The below output is of: df_avg=df.groupby(['col1']).mean() col1 col2 col3 A 2.20 5.20 B 3.57 2.86 C 4.15 6.40 H 3.50 4.03 Similarly I want pct_change().sum() by group