I have a pandas dataframe (which was created by importing a csv file). I want to replace empty values ββwith NaN. Some of these empty values ββare empty, and some contain (variable number) spaces '' , ' ' , ' ' , etc.
Using this thread sentence I have
df.replace(r'\s+', np.nan, regex=True, inplace = True)
which replaces all lines containing only spaces, but also replaces every line that has a space, and that is not what I want.
How to replace only lines with spaces and empty lines only?
source share