I have a dataframe with 2 columns 'Date' and 'Temp':
Temp
Date
2017-08-31 43.8532
2017-08-30 44.1702
2017-08-29 43.7581
2017-08-28 43.8680
2017-08-25 43.5181
2017-08-24 43.9274
2017-08-23 43.6600
2017-08-22 43.5773
2017-08-21 43.7247
2017-08-18 43.7179
2017-08-17 43.7072
2017-08-16 43.3215
2017-08-15 43.3597
2017-08-14 43.3082
2017-08-11 43.5351
2017-08-10 43.6848
... ...
31/08/2016 37.873
30/08/2016 38.6831
29/08/2016 38.7264
26/08/2016 39.1932
25/08/2016 39.1318
... ...
I wish to create 2 new columns '1 yr diff' and '1 yr std'
'1 yr diff' is the difference in temperature between 2 dates a year apart.
'1 yr std' is the standard deviation in temperature during the past year.
Calculated by hand for the first three:
Date Temp 1 yr diff 1 yr std
31/08/2017 43.8532 5.9802 1.914
30/08/2017 44.1702 5.4871 1.909
29/08/2017 43.7581 5.0317 1.901
How do I do this for all the rows?