What I wanted to do is to replace a single entry NaN value of pandas DataFrame to a single string. Here is what I did.
s = pd.DataFrame({'A':['S12','S1','E53',np.NaN], 'B':[1,2,3,4]})
s['A'][s['A'].isnull()==True] = 'P'
This code will try to find 'NaN' value in the DataFrame and replace it to the string 'P' and result looks like this.
A B
0 S12 1
1 S1 2
2 E53 3
3 P 4
But I also get a warning like this:
/Users/grr/anaconda/bin/ipython:3: 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
# -*- coding: utf-8 -*-
Could anyone explain to me what this means and what I should do to avoid this?
Thank you!