Howardyan
Howardyan

Reputation: 667

pandas dataframe compare None puzzle me

import pandas as pd

a = [{'a':None},{'a':"11"},{'a':None}]
df = pd.DataFrame(a)

I try to find the 'a' which is None, So I write this:

df.a == None

and the result is:

0    False
1    False
2    False
Name: a, dtype: bool

but I use map function:

df.a.map(lambda x: x == None)

the result is right:

0     True
1    False
2     True
Name: a, dtype: bool

as a newbie, the different result really puzzle me..

panda version: 0.19.2

Can anybody help me? Why the first way can not work properly.

Best regards

Upvotes: 0

Views: 43

Answers (1)

Allen Qin
Allen Qin

Reputation: 19957

please use the below function to check None.

df.a.isnull()

Upvotes: 1

Related Questions