title: Pandas Performance comparison apply vs map
body: <p>I'm comparing the performance of calculating a simple multiplication of a Dataframe column using both <code>map</code> and <code>apply</code></p>
  
  <p>I expected the <code>apply</code> version to be much, much faster because I'm doing a vectorized numpy function instead of operating on an element at a time.</p>
  
  <p>However, it was not the case, both version had equal performance:</p>
  
  <p>apply version:</p>
  
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  import numpy as np
  
  np.random.seed(42)
  
  df1 = pd.DataFrame({
      'x': np.random.random(size=10000000)
  })
  
  df1['2x'] = df1['x'].apply(lambda arr: arr*2)
  # CPU times: user 1.64 s, sys: 180 ms, total: 1.82 s
  # Wall time: 1.82 s
  </code></pre>
  
  <p>map version:</p>
  
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  import numpy as np
  
  np.random.seed(42)
  
  df2 = pd.DataFrame({
      'x': np.random.random(size=10000000)
  })
  
  df2['2x'] = df2['x'].map(lambda element: element *2)
  # CPU times: user 1.65 s, sys: 180 ms, total: 1.83 s
  # Wall time: 1.83 s
  </code></pre>
  
  <p>Versions used: Python 3.6.7, Pandas 0.24.2, Numpy 1.16.3</p>
  
  <p><strong>Why isn't the <code>apply</code> version much faster than the <code>map</code> version, since it's using numpy vectorized functions?</strong></p>