how to replace a value by blank value in pandas code example Example: pandas replace empty string with nan df = df.replace(r'^\s*$', np.NaN, regex=True)