I'm trying to assign some labels on a column based on the values of another column. The values of the column 'Percentage_delay' range from 0 to 1. If the value of the column 'Percentage_delay' is more than 0.75 the corresponding value on the column 'Labels' is supposed to be 'high', if less then 0.75 and more than 0.5 'medium', if less than 0.5 'low'.
I come up with this code:
for i in number_delay_aiport['Percentage_delay']:
if i >= 0 and i < 0.25:
number_delay_aiport['Labels'] = 'low'
if i >= 0.25 and i < 0.75:
number_delay_aiport['Labels'] = 'medium'
if i >= 0.75 and i <= 1:
number_delay_aiport['Labels'] = 'high'
The output is wrong, since I have only the value 'high': Output
The same happens if a use the function 'return'.
Could you please tell me why it happens?
Aucun commentaire:
Enregistrer un commentaire