Reputation: 53
df
Letter city state
0 A NYC NY
1 B Na CT
2 C LA Na
3 D Tampa FL
4 E Na Na
5 F Dallas TX
6 G Denver CL
df['city']=df['city'].str.replace("Na"," ")
df['state']=df['state'].str.replace("Na"," ")
df
Letter city state
0 A NYC NY
1 B CT
2 C LA
3 D Tampa FL
4 E
5 F Dallas TX
6 G Denver CL
df.isnull().any()
Letter False
city False
state False
dtype: bool
How to empty Na to become:
Letter False
city True
state True
Upvotes: 0
Views: 71
Reputation: 21264
Starting with your original df
, you can just do:
df.eq("Na").any()
Alternately, starting from the second df
, after you replace Na
with empty string, replace the empty strings with NaN
:
import numpy as np
df.replace('', np.nan).isnull().any()
Both produce:
Letter False
city True
state True
dtype: bool
Upvotes: 2