Calculate difference between values in consecutive rows by group
Hi There, I have a data table with 2 columns like the below:group value
1 10
1 20
1 25
2 5
2 10
2 15
I want to create a new column, "diff", that calculates the differences between consecutive rows, grouped by "group", so I would have something like this: group value diff
1 10 . # because there is a no previous value
1 20 10 # value[2] - value[1]
1 25 5
...