python replace empy string with nan code example
Example 1: pandas replace empty string with nan
df = df.replace(r'^\s*$', np.NaN, regex=True)
Example 2: python pandas replace nan with null
df.fillna('', inplace=True)
df = df.replace(r'^\s*$', np.NaN, regex=True)
df.fillna('', inplace=True)