title: if statement/conditions to check a dataframe column for a string in Python
body: <p>I have a column with text like &quot;Dublin 2&quot;, &quot;Dublin 4&quot; etc in it. There are up to 24 Dublins that I need to check for.</p>
  <p>I want to do something like:</p>
  <pre><code>if df[&quot;Postcode&quot;] == &quot;Dublin 2&quot;:
      df[&quot;Popularity&quot;] == 10
          
  elif df[&quot;Postcode&quot;] == &quot;Dublin 3&quot;:
      df[&quot;Popularity&quot;] == 3
  </code></pre>
  <p>etc</p>
  <p>I have tried using conditions and np.select, it works but that's not feasible for the number of Dublins I have.</p>
  <pre><code>conditions = [
  
      df['Dublin Postcode'].str.contains('Dublin 1'),
      df['Dublin Postcode'].str.contains('Dublin 2'),
      
      ]
  
  values = [10,3]
  
  df['Popularity'] = np.select(conditions, values, default=5) 
  </code></pre>
  <p>Is there a smarter way of getting it to work? I can't see the wood for the trees at this stage!</p>