Correct way to set value on a slice in pandas
<p>I have a pandas dataframe: data. it has columns ["name", 'A', 'B'] </p>

<p>What I want to do (and works) is:</p>

<pre><code>d2 = data[data['name'] == 'fred'] #This gives me multiple rows
d2['A'] = 0
</code></pre>

<p>This will set the column A on the fred rows to 0. 
I've also done:</p>

<pre><code>indexes = d2.index
data['A'][indexes] = 0
</code></pre>

<p>However, both give me the same warning: </p>

<pre><code>/Users/brianp/work/cyan/venv/lib/python2.7/site-packages/pandas/core/indexing.py:128: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
</code></pre>

<p>How does pandas WANT me to do this?</p>