Adding a column thats result of difference in consecutive rows in pandas

Use shift.

df['dA'] = df['A'] - df['A'].shift(-1)

Leave a Comment