I have a dataframe that looks like that (Date is the index):

```
Date    Value   Sensor
19/08/2021  8787    A
20/08/2021  7360    A
23/08/2021  17570   A
24/08/2021  18993   A
25/08/2021  17947   A
26/08/2021  18317   A
27/08/2021  16940   A
30/08/2021  23837   A
31/08/2021  18353   A
19/08/2021  15010   B
20/08/2021  10873   B
23/08/2021  5270    B
24/08/2021  21060   B
25/08/2021  13430   B
26/08/2021  6267    B
27/08/2021  33677   B
30/08/2021  9460    B
31/08/2021  8223    B

```

I need to calculate a new column that would be the current value of the value column divided by the value 5 days ago, plus the value of 5 days ago divided by the value 15 days ago. This has to be done for each sensor. Values which cannot be calculated can be filled with NA or anything meaningless. This is what I would like to get as reslt:

```
Date    Value   Sensor  Calc
2/08/2021   8247    A   NA
3/08/2021   20267   A   NA
4/08/2021   10507   A   NA
5/08/2021   10397   A   NA
6/08/2021   15513   A   NA
9/08/2021   10063   A   NA
10/08/2021  7787    A   NA
11/08/2021  7607    A   NA
12/08/2021  12823   A   NA
13/08/2021  10410   A   NA
16/08/2021  12810   A   NA
17/08/2021  22507   A   NA
18/08/2021  15050   A   NA
19/08/2021  8787    A   NA
20/08/2021  7360    A   NA
23/08/2021  17570   A   2.924876806
24/08/2021  18993   A   1.954395294
25/08/2021  17947   A   2.624870109
26/08/2021  18317   A   2.92970437
27/08/2021  16940   A   2.776071226
30/08/2021  23837   A   3.102687734
31/08/2021  18353   A   3.405368483
2/08/2021   18170   B   NA
3/08/2021   11347   B   NA
4/08/2021   10657   B   NA
5/08/2021   18710   B   NA
6/08/2021   8707    B   NA
9/08/2021   8490    B   NA
10/08/2021  11043   B   NA
11/08/2021  10953   B   NA
12/08/2021  9663    B   NA
13/08/2021  20227   B   NA
16/08/2021  14010   B   NA
17/08/2021  15863   B   NA
18/08/2021  11583   B   NA
19/08/2021  15010   B   NA
20/08/2021  10873   B   NA
23/08/2021  5270    B   1.147211069
24/08/2021  21060   B   2.725608385
25/08/2021  13430   B   2.246349071
26/08/2021  6267    B   1.219766441
27/08/2021  33677   B   4.346070613
30/08/2021  9460    B   2.415796685
31/08/2021  8223    B   2.297546305

```

Within one sensor, I can do it with something like

```
df['Calc'] = (df.iloc[:, 1].div(df.iloc[:, 1].shift(5))+df.iloc[:, 1].shift(15).div(df.iloc[:, 1].shift(15))

```

but I am struggling to do it within the group.

Bonus question :-) Once the calculation is done I need to transpose the dataframe and use sensor as index and dates as column headers with "Calc"s as horizontal values.

Appreciate your help!