title: Pandas Boolean .any() .all()
body: <p>I kept getting <code>ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().</code> when trying boolean tests with pandas. Not understanding what it said, I decided to try to figure it out. </p>
  
  <p>However, I am totally confused at this point.</p>
  
  <p>Here I create a dataframe of two variables, with a single data point shared between them (3):</p>
  
  <pre><code>In [75]:
  
  import pandas as pd
  
  df = pd.DataFrame()
  
  df['x'] = [1,2,3]
  df['y'] = [3,4,5]
  </code></pre>
  
  <p>Now I try all(is x less than y), which I translate to "are all the values of x less than y", and I get an answer that doesn't make sense.</p>
  
  <pre><code>In [79]:
  
  if all(df['x'] &lt; df['y']):
      print('True')
  else:
      print('False')
  True
  </code></pre>
  
  <p>Next I try any(is x less than y), which I translate to "is any value of x less than y", and I get another answer that doesn't make sense.</p>
  
  <pre><code>In [77]:
  
  if any(df['x'] &lt; df['y']):
      print('True')
  else:
      print('False')
  False
  </code></pre>
  
  <p>In short: what does any() and all() actually do?</p>