I am working with a df and using numpy to transform data - including setting blanks (or \'\') to NaN. But when I write the df to csv - the output contains the string \'nan\' as
Using df.replace may help -
df = df.replace(np.nan, '', regex=True) df.to_csv("df.csv", index=False)
(This sets all the null values to '' i.e empty string.)