pandas df replace nan with string in selected column code example
Example 1: pandas replace empty string with nan
df = df.replace(r'^\s*$', np.NaN, regex=True)
Example 2: replace "-" for nan in dataframe
df.replace(np.nan,0)
df = df.replace(r'^\s*$', np.NaN, regex=True)
df.replace(np.nan,0)