df fruit date price cost var1
0 apple 2017-01-01 2 2 20
1 apple 2017-01-02 3 3 40
2 banana 2017-01- 02 4 4 20
2 banana 2017-01-02 4 4 10
Is there a way to generate a first-difference dataframe (fd_df) that keeps fruit,var1,date from df but first-differences all remaining variables by fruit? I have 20 columns to first-difference (including price and cost) so need generalised code.