I have a data frame df
with 120 columns named asA,B,C,D
etc. Lets say A looks like this:
A
31
12
51
72
81
..
I want to create a column SDA that will have a standard deviation of the elements of A
in such a way that the first value of SDA will be the standard deviation of the first value of A
, the second value of SDA will be the Standard Deviation of first two value of A
.The third value of SDA will be the standard deviation of initial 3 values of column A
etc.
SDA
x1
x2
x3
x4
x5
...
here x1 will calculate SD of 31 (SD value may be 0, as only one value ), x2 will calculate SD of 31,12. Then the next one will consider 31,12,51. Next 31,12,51,71 and so on.
How can I carry out such an operation and generate such a Standard deviation column for every column (that will result in generating many SD columns at a time I have in df
at the same time?