Skip to content
Advertisement

Python DataFrame String replace accidently Returing NaN

I encounter a weird problem in Python Pandas, while I read a excel and replace a character “k”, the result gives me NaN for the rows without “K”. see below image

enter image description here

It should return 173 on row #4,instead of NaN, but if I create a brand new excel, and type the same number. it will work.

or if i use this code,

JavaScript

enter image description here

then it will works well. Why? please advise!

Advertisement

Answer

Try this:

JavaScript
Advertisement