how to replace empty string with null in pandas?

3k Views Asked by At

empty string like this isnull() not find empty string

conn = connect(host='localhost',port=3306,user='root',password='root',database='spiderdata',charset='utf8')
df = pd.read_sql('select * from beikedata_community1',con=conn)
df
df.subway.isnull()

**i want to use 'isnull()' find missing value, but it's not support empty string, what can i do? thanks very much!**
1

There are 1 best solutions below

9
Anirudh On

You can use print(df.replace(r' ', 'NaN')) . This Replaces the empty cells with NaN.