My df is as follows:
What I want to do is,
Condition: Fruit Name
is NOT (Apple or Mango
) and veggie Name
== No
Action: Set values in Veggie Color
and Enjoy Eating
= Unicorn
My code is
df.loc[(~df["Fruit Name"].isin(["Apple","Mango"]))& (df["Veggie Name"]=="Potato"),["Veggie Color","Enjoy Eating"]]="Unicorn"
While it does so as follows
It sets NaN to other cells
What am I missing?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…