0

When I apply fillna('New_Value) to the df below it fills all the None and NaN values except Column:D at Index 1.

So what is the reason?

Here is my code

df=pd.DataFrame([{'A':None,'B':False,'C':1,'D':'a','E':np.NaN,'F':True,'G':'a','H':np.NaN},{'A':1,'B':2,'C':3,'D':'None','E':1,'F':True,'G':'b'},
                 {'A':False,'B':None,'C':None,'D':True,'E':2,'F':True,'G':'b','H':None},
                    {'A':'a','B':'b','C':1,'D':'b','E':3,'F':False,'G':'c','H':np.NaN},
                     {'A':None,'B':4,'C':6,'D':'c','E':None,'F':False,'G':'c','H':None},
                     {'A':None,'B':4,'C':6,'D':'c','E':None,'F':True,'G':'d','H':True},
                     {'A':True,'B':False,'C':True,'D':False,'E':True,'F':False,'G':False}])
Mr. T
  • 11,960
  • 10
  • 32
  • 54
  • Welcome to StackOverflow. Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. – jezrael May 02 '18 at 11:11
  • 2
    [Question that were caused by a simple typographical error are considered off-topic.](https://stackoverflow.com/help/on-topic) – Mr. T May 02 '18 at 11:21

1 Answers1

0

You wrote None in that case as string. Remove the quotes '

df = pd.DataFrame([{'A':None,'B':False,'C':1,'D':'a','E':np.NaN,'F':True,'G':'a','H':np.NaN},{'A':1,'B':2,'C':3,'D':None,'E':1,'F':True,'G':'b'}, ...)

If you cannot modify the df, replace the string:

df = df.replace({'None':'New_Value'})
Joe
  • 12,057
  • 5
  • 39
  • 55