NaN is not equivalent to empty strings or 0 with python pandas code example Example: pandas replace empty string with nan df = df.replace(r'^\s*$', np.NaN, regex=True)