samedi 16 mai 2020

Use of if to create new column [duplicate]

I´m trying to create a new column in an existing dataframe, depending on another current column whit this piece of code:


if [(df_bank_c2['y']=='yes')]:
    df_bank_c2['new_y'] = 1
elif [(df_bank_c2['y']=='no')]:
    df_bank_c2['new_y'] = 0

But the holes values of 'new_y' are 1 (no one takes 0). Where am I wrong? Thx

Aucun commentaire:

Enregistrer un commentaire