with columns as L, W, H, D. Each of them have range from 10 to 100, if it goes beyond this it is fail else it is pass
How can i simplify this code. I tried using if condition which failed
def Target(FM):
if (df['L'] < 10 or df['L'] > 120):
return 'L-Fail'
else:
return 'Pass'
elif (df['W'] < 10 or df['W'] > 120):
return 'W-Fail'
else:
return 'Pass'
elif (df['H'] < 10 or df['H'] > 120):
return 'H-Fail'
else:
return 'Pass'
elif(df['D'] < 10 or df['D'] > 120):
return 'D-Fail'
else:
return 'Pass'
df['Remarks_Target'] = df.apply(Target, axis = 1)
L W H D Remarks
1 20 30 40 L-Fail
10 40 0 50 H-Fail
15 30 30 60 Pass
60 90 80 300 D-Fail
50 0 30 120 W-Fail
10 10 120 120 Pass
Aucun commentaire:
Enregistrer un commentaire