mardi 25 août 2020

one line if statement, ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

I am getting this error when I try to add a column to my pandas dataset based on the following conditions.

df['name'] = (1 if (df['name2'] > 0) and (df['name3'] == 0) else 0)

I would really appreciate some help with this, I am very new to python.

Thanks.

Aucun commentaire:

Enregistrer un commentaire