I have an excel sheet with multiple columns, three of them are named X Y Z. I'm trying to apply the same formula to the three columns using panda dataframe. I need to subtract the last value in the column from every cell value in that column; save new value and keep going down the column. Is there a way to do this without iterating over every row? This process has to be performed on each of the columns X Y and Z only.
INPUT
T X Y Z vx vy vz
0 0 0 3 3 4 5
1 0 1 4 4 4 6
2 23 6 9 5 6 6
3 35 9 9 7 7 8
Output
T X Y Z vx vy vz
0 -35 -9 -6 3 4 5
1 -35 -8 -5 4 4 6
2 -12 -3 0 5 6 6
3 0 0 0 7 7 8