我有一个熊猫数据框:data. 它有列 ["name", 'A', 'B']
我想做(和工作)的是:
d2 = data[data['name'] == 'fred'] #This gives me multiple rows
d2['A'] = 0
这会将 fred 行上的 A 列设置为 0。我也做了:
indexes = d2.index
data['A'][indexes] = 0
但是,两者都给了我同样的警告:
/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
熊猫要我怎么做?