i have a df which a part of is similar to the following
| Number|Category| A1|A2|B1|B2|C1|C2|A |B |C |
| ------| -------|---|--|--|--|--|--|--|--|--|
| 1 | 1 | 10|30|5 |15|NA|NA|5 |10|NA|
| 2 | 2 | 10|30|5 |15|25|35|40|20|45|
A1-A2, B1-B2, C1-C2 are the limits of the factors A, B, C and columns A, B, C represent the measurements. If the measurement is under the lower limit the factor is "passed", if it is in the middle then the factor is in "danger", if the measurement is higher than the higher limit then it is " failed". For the category=1 we are permitted to have only 1 failure in one of the factors and in that case we classify the asset as "risk", but if we have 2 failures then the asset in the row 1 "fail".
Category=2 permitted 2 failures. If one factor fails is at "at risk, if we have 2 failures is "risk" and we have 3 failures then its "fail".
So I would like to calculate for every row(asset) the status of every factor and then the status of the asset. I am trying to that with a for loop and an if-else statement that iterates through all these columns of every row but seems difficult as I am a beginner. The final result is to attach the following columns to the dataset. Thank you in advance
|Number|Aa |Bb |Cc |Result |
|------|------|------|------|-------|
|1 |passed|danger|NA | risk |
|2 |failed|failed|failed| failed|
Aucun commentaire:
Enregistrer un commentaire