I am trying to replace the nan values in a dataframe column 'Functional' using fillna()
function. The issues I am facing are below:
- I am able to detect the null values using the
isnull()
dfcomp[dfcomp['Functional'].isnull()==True]
- using above index I searched the actual value
dfcomp['Functional'][2216]
- but when I try to fill the nan using
fillna()
, nothing happens. Even after running the fillna statement I can rerun the first statement and see the same 2 nan instances.
dfcomp['Functional']=dfcomp['Functional'].fillna(value=dfcomp['Functional'].mode())
I have tried both versions btw
dfcomp['Functional'].fillna(value=dfcomp['Functional'].mode(),inplace=True)
- I also tried using the
replace()
function for this but no luck
dfcomp['Functional']=dfcomp['Functional'].replace({'nan':dfcomp['Functional'].mode()})
Is there something wrong with my code? why is fillna()
not recognizing the nan
when isnull()
can do so?
Also, why is the index search showing the value as nan
but when I try to replace the same value using replace()
there is no result?
How can I replace the nan values when my fillna()
is not able to recognize it?