title: How to fixed 'ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().' when & is used
body: <p>I want to reassign values based on multiple columns conditions, but the <code>ValueError</code> appears. I used <code>&amp;</code> instead of <code>and</code>, which was often the answer to solve such error. My goal and codes are as following:</p>
  
  <pre><code>ValueError: The truth value of a DataFrame is ambiguous. 
  Use a.empty, a.bool(), a.item(), a.any() or a.all().
  </code></pre>
  
  <p>I want to recode <code>YearsInCanada == Age</code>  if <code>CountryBorn == Canada</code> and <code>YearsInCanada == None</code></p>
  
  <pre><code>df
  Age    CountryBorn    YearsInCanada
  87     NaN            77      
  67     Canada         67
  29     US             7
  26     US             10
  22     US             12
  35     Canada         NaN
  45     Canada         NaN
  
  expected output
  Age    CountryBorn    YearsInCanada
  87     NaN            77      
  67     Canada         67
  29     US             7
  26     US             10
  22     US             12
  35     Canada         35
  45     Canada         45
  </code></pre>
  
  <p>My following codes showed the <code>ValueError</code></p>
  
  <pre><code>    if df.loc[(df['YearsInCanada'] == None) &amp; (df['CountryBorn'] == 'Canada')]:
          df['YearsInCanada'] == df['Age']
  
      else:
          df['YearsInCanada'] == df['YearsInCanada']
  </code></pre>
  
  <p>Thanks</p>