So I am trying to find rows where data indicates casualty - in this case, the dataset identifies an alarm signal, which then results in an error signal in the dataset between 1 and 14 days later.
Is it possible to create a 'fault' column, whereby once an alarm signal is detected, the 'fault' column is set to True for up to the next 14 days? df.loc attempts work but will only change one row for the corresponding day, whereas I would like a solution that can edit the corresponding day and the remaining 13 days too! This way I can then check the date of the error signal against the range of dates of alarm signals, to determine if the fault actually occurred.
eg. pseudo data
time vibration_value fault?
2007-06-01 50 False
2007-06-02 47 False
2007-06-03 29 False
2007-06-04 52 False
2007-06-05 455 True
2007-06-06 672 True
2007-06-07 513 True
2007-06-08 532 True
2007-06-09 510 True
2007-06-10 498 True
2007-06-11 12 False
2007-06-12 25 False
2007-06-13 19 False
2007-06-14 46 False
I'm achieving this for the first fault result with the below code, but am unsure how to get this to edit the subsequent rows.
df.loc[df['vibration_value'] >= 250, 'Fault'] = True
df['vibration_value'] >= 520and need last 3 days?