I need to change values by another values with any conditions in pandas dataframe, but get error:
>>> df
X0 X1 X2
0 a 1 0
1 b 3 0
2 c 2 0
3 c 4 0
formula: if (X0 != "a" and X0 != "b") set X2 = X0+X1
result will be :
>>> df
X0 X1 X2
0 a 1 0
1 b 3 0
2 c 2 c2
3 c 4 c4
I try to use:
df.loc[df.X0!= "a" and df.X0!= "b" ,"X2"]= df.X1+dfX2
but get " ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()."