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