title: Why is numpy select is slower than a custom function via apply method?
body: <p>Say, I have the following dataframe:</p>
  <pre><code>df = pd.DataFrame({'a':['a','b','c (not a)', 'this is (random)']*10000})
  </code></pre>
  <p>I want to produce the following output:</p>
  <pre><code>array(['same as column', 'b', 'c', 'this is']*10000, dtype=object)
  </code></pre>
  <p>Towards that end, I defined the function below and passed it via the pandas apply method.</p>
  <pre><code>def fn(x):
      if ' (' in x:
          return x.split(' (')[0]
      elif x=='a':
          return 'same as column'
      else:
          return x
  
  df['a'] = df['a'].apply(fn)
  </code></pre>
  <p>Then, others advised me to use vectorization, so I used the code below to produce my desired output.</p>
  <pre><code>df = np.select([df['a'].str.contains(' \('), df['a']=='a'], 
                 [df['a'].str.split(' \(').str[0], 'same as column'], 
                 default=df['a'])
  </code></pre>
  <p>Instead of running faster, this vectorized version ran noticeably slower.</p>
  <p><code>21.4 ms ± 1.87 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)</code> for the apply method</p>
  <p><code>116 ms ± 21.7 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)</code> for the vectorization</p>
  <p>What's going on here? Is this normal (I thought vectorization was the fastest option available)? Or is there a problem with my code?</p>