I have a pandas df that looks like this for example:
%diff
-0.087704164
0.003908466
-0.032150706
-0.035684163
0.001682029
-0.072205803
0.031636864
-0.069263158
-0.214883511
-0.109286469
0.274932615
-0.016913319
-0.075268817
0.191906977
0.043861703
-0.048598131
0.01280943
0.014509621
0.075564054
-0.024034701
0.009107468
0.023465704
I want to calculate the square root of 252 multiple by the standard deviation of the last 20 values in the column '%diff.
%diff std
-0.087704164
0.003908466
-0.032150706
-0.035684163
0.001682029
-0.072205803
0.031636864
-0.069263158
-0.214883511
-0.109286469
0.274932615
-0.016913319
-0.075268817
0.191906977
0.043861703
-0.048598131
0.01280943
0.014509621
0.075564054
-0.024034701 165.9%
0.009107468 163.2%
0.023465704 163.4%
The code I tried is:
df1['std'] = 252**(1.0/2) * df1['%diff'].std().split(20)
But I get an unsupported operand error