Darp Ag
Darp Ag

Reputation: 1

isnull() in pandas not able to identify blank value (Python coding)

import pandas as pd
t1=pd.DataFrame()
t1 ['name'] = ["dp","ag","wp"]
t1['status'] = ['a','b','c']
t1['age'] = [10,"",15]
t1
##
print(t1.isnull().values)

Why is the execution of this node not able to identify blank (see "age" column, 2nd row). isnull() is coming false for all the cells, see below output Output:

 [[False False False] 
 [False False False] 
 [False False False]] 

Upvotes: 0

Views: 1634

Answers (1)

jezrael
jezrael

Reputation: 862781

Because empty string is not same like missing value. So correct test for it is:

print(t1.eq('').values)

Or:

print((t1 == '').values)

If want test empty strings or missing values chain both mask with | for bitwise OR:

print((t1.isnull() | t1.eq('')).values)

Upvotes: 1

Related Questions