filling blank values in pandas with 0 code example Example: pandas replace empty string with nan df = df.replace(r'^\s*$', np.NaN, regex=True)