I have a column A, which has values Y and N. I want to assign 1 for Y and 0 of N, using the if condition in python. The following code throws an error: ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
if df1[df1['A']=='Y']:
df1['A']=1
else:
df1['A']=0
Aucun commentaire:
Enregistrer un commentaire