title: Pandas map to a new column, SettingWithCopyWarning
body: <p>In pandas data frame, I'm trying to map df['old_column'], apply user defined function <em>f</em> for each row and create a new column.</p>
  
  <pre><code>df['new_column'] = df['old_column'].map(lambda x: f(x))
  </code></pre>
  
  <p>This will give out "SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame." error.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>df.loc[:, 'new_column'] = df['old_column'].map(lambda x: f(x))
  </code></pre>
  
  <p>which doesn't help. What can I do?</p>