mercredi 8 novembre 2017

Doing conditional and changes in date frame cells [duplicate]

What I want to do:

if my avg_df = 0 and my prediction_df = 0 then set my percentage_df = 100

What I tried to write:

percentage_df = percentage_df.mask(avg_df==0 and prediction_df==0,100)

df stands for date frame as they are all date frame. I just want to change the elements of percentage_df that matches two these two conditions at same time.

My problem: This is not working.

ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Any help? Appreciated

Aucun commentaire:

Enregistrer un commentaire