I have a df named value of size 567 and it has a column index as follows:
index
96.875
96.6796875
96.58203125
96.38671875
95.80078125
94.7265625
94.62890625
94.3359375
58.88671875
58.7890625
58.69140625
58.59375
58.49609375
58.3984375
58.30078125
58.203125
I also have 2 additional variables:
mu = 56.80877955613938
sigma= 17.78935620293665
What I want is to check the values in the index column. If the value is greater than, say, mu+3*sigma, a new column named alarm must be added to the value df and a value of 4 must be added.
I tried:
for i in value['index']:
    if (i >= mu+3*sigma):
        value['alarm'] = 4
    elif ((i < mu+3*sigma) and (i >= mu+2*sigma)):
        value['alarm'] = 3
    elif((i < mu+2*sigma) and (i >= mu+sigma)):
        value['alarm'] = 2
    elif ((i < mu+sigma) and (i >= mu)):
        value['alarm'] = 1
But it creates an alarm column and fills it completely with 1.
What is the mistake I am doing here?
Expected output:
index            alarm
96.875             3
96.6796875         3
96.58203125        3
96.38671875        3
95.80078125        3
94.7265625         3
94.62890625        3
94.3359375         3
58.88671875        1
58.7890625         1
58.69140625        1
58.59375           1
58.49609375        1
58.3984375         1
58.30078125        1
58.203125          1
 
    