title: Pandas SettingWithCopyWarning
body: <p>Python 3.4 and Pandas 0.15.0</p>
  
  <p>df is a dataframe and col1 is a column. With the code below, I'm checking for the presence of the value 10 and replacing such values with 1000. </p>
  
  <pre><code>df.col1[df.col1 == 10] = 1000
  </code></pre>
  
  <p>Here's another example. This time, I'm changing values in col2 based on index.</p>
  
  <pre><code>df.col2[df.index == 151] = 500
  </code></pre>
  
  <p>Both these produce the warning below:</p>
  
  <pre><code>-c:1: SettingWithCopyWarning: 
  A value is trying to be set on a copy of a slice from a DataFrame
  
  See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  </code></pre>
  
  <p>Finally,</p>
  
  <pre><code>cols = ['col1', 'col2', 'col3']
  df[cols] = df[cols].applymap(some_function)
  </code></pre>
  
  <p>This produces a similar warning, with an added suggestion:</p>
  
  <pre><code>Try using .loc[row_indexer,col_indexer] = value instead
  </code></pre>
  
  <p>I'm not sure I understand the discussion pointed to in the warnings. What would be a better way to write these three lines of code?</p>
  
  <p>Note that the operations worked.</p>