vendredi 30 mars 2018

wanted to create flag for salary in python

if salary > 200 then flag='high' else 'low'. test1 is my DataFrame. I'm using below code:

for i in test1['salary']:
    if i > 200:
       test1['flag']='high'
    elif i < 200:
       test1['flag']='low'

print (test1)

it's giving me flag = high only.

Aucun commentaire:

Enregistrer un commentaire