Change value of all rows in a column of pandas data frame
<p>I have a data frame <code>df</code> like:</p>

<pre><code>        measure  model threshold
285   0.241715  a        0.0001
275   0.241480  a        0.0001
546   0.289773  b        0.0005
556   0.241715  b        0.0005
817   0.357532  a         0.001
827   0.269750  b         0.001
1088  0.489164  a        0.0025
</code></pre>

<p>I want to change all values in the column <code>model</code> to <code>'no_model'</code>. How do I do this?</p>

<p>I am currently doing <code>df['model'] = 'no_model'</code>, but I'm getting:</p>

<pre><code>SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  df['model'] = 'no_model'
</code></pre>

<p>You get the warning because you probably either made a reference to the original df:</p>

<p><code>df1 = df</code></p>

<p>and then tried your code but your intention was to take a copy so you should use <code>copy()</code> to explicitly take a copy:</p>

<p><code>df_copy = df.copy()</code></p>

<p>this will get rid of the warning</p>

python pandas dataframe slice