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
如何清空Na成为:
Letter False
city True
state True
答案 0 :(得分:2)
从原始的df
开始,您可以这样做:
df.eq("Na").any()
或者,从第二个df
开始,用空字符串替换Na
之后,用NaN
替换空字符串:
import numpy as np
df.replace('', np.nan).isnull().any()
两种产品:
Letter False
city True
state True
dtype: bool