title: Pandas df error - "The truth value of a Series is ambiguous." in if else loop
body: <p>I have a pandas df with a column called <em>group</em> consisting of three values which are 1,2 and 3.</p>
  
  <p>I am trying to do the following if else statement:</p>
  
  <pre><code>if df.group == 1:
     (code here)
  elif df.group ==2:
     (code here)
  else:
     (code here)
  </code></pre>
  
  <p>When I try to run my if else loop it is throwing the following error:
  <em>ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().</em></p>
  
  <p>Do I need to use np.where instead of the if else loop on the dataframe or if there a way to achieve this with the if else loop? </p>