Piyush S. Wanare
Piyush S. Wanare

Reputation: 4933

How to check Pandas cell value is nan

I am getting value of cell as nan, But when I do cell_value == np.nan then it's False.

Then I tried to print type(cell_value) it's giving <class 'float'>

How do I match it ?

Upvotes: 3

Views: 6139

Answers (1)

iDrwish
iDrwish

Reputation: 3103

You can't use equality on nan, you can evaluate it as follows:

np.isnan(np.nan)
#returns True

pd.isnull(np.nan)
#returns True

np.nan == np.nan
#Always returns False

Because nan is a special floating point value.

Upvotes: 6

Related Questions