First I build a new DataFrame frame. Then create a new frame2 by filtering some data from frame. Now I want to assign some value to frame2:
import numpy as np
from pandas import DataFrame
frame = DataFrame(np.arange(9).reshape((3, 3)), index=['a', 'c', 'd'], columns=['Ohio', 'Texas', 'California'])
mask = frame['Texas'] > 1
print frame[mask]
frame2 = frame.loc[mask]
frame2.loc['c', 'Ohio'] = 'me'
print frame2
but I got this warning:
C:\Python27\lib\site-packages\pandas\core\indexing.py:461: 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
why I keep got this warning although I used the recommended .loc syntax? what i supposed to do to avoid this warning?