I have a pandas dataframe (that was created by importing a csv file). I want to replace blank values with NaN. Some of these blank values are empty and some contain a (varia
Indicate it has to start with blank and end with blanks with ^ and $ :
df.replace(r'^\s*$', np.nan, regex=True, inplace = True)