title: Python Pandas Dataframe Conditional If, Elif, Else
body: <p>In a Python Pandas <code>DataFrame</code>, I'm  trying to apply a specific label to a row if a 'Search terms' column contains any possible strings from a joined, pipe-delimited list.  How can I do conditional if, elif, else statements with Pandas?</p>
  
  <p>For example:</p>
  
  <pre><code>df = pd.DataFrame({'Search term': pd.Series(['awesomebrand inc', 'guy boots', 'ectoplasm'])})
  
  brand_terms = ['awesomebrand', 'awesome brand']
  footwear_terms = ['shoes', 'boots', 'sandals']
  
  #Note: this does not work
  if df['Search term'].str.contains('|'.join(brand_terms)):
    df['Label'] = 'Brand'
  elif df['Search term'].str.contains('|'.join(footwear_terms)):
    df['Label'] = 'Footwear'
  else:
    df['Label'] = '--'
  </code></pre>
  
  <p>Example desired output:</p>
  
  <pre><code>Search Term          Label
  awesomebrand inc     Brand
  guy boots            Footwear
  ectoplasm            --
  </code></pre>
  
  <p>I've tried appending <code>.any()</code> to the ends of the <code>contains()</code> statements but it applies the <code>Brand</code> label to every row.</p>
  
  <p>Most of the examples I come across are comparing if a column value <code>==</code> is equal to (not what I want) or are performing numeric comparisons, not text string comparisons.</p>