I am using if in a conditional statement like the below code. If address is NJ then the value of name column is changed to 'N/A'
df1.loc[df1.Address.isin(['NJ']), 'name'] = 'N/A'
How to do the same, if I have 'nested if statements' like below
# this not code just representing the logic
if address isin ('NJ', 'NY'):
if name1 isin ('john', 'bob'):
name1 = 'N/A'
if name2 isin ('mayer', 'dylan'):
name2 = 'N/A'
Can I achieve above logic using df.loc ? Or is there any other way to do it ?
Aucun commentaire:
Enregistrer un commentaire