Pandas Replace NaN with blank/empty string – Stack Overflow

Source: python – Pandas Replace NaN with blank/empty string – Stack Overflow

If you are reading the dataframe from a file (say CSV or Excel) then use :

df.read_csv(path , na_filter=False)
df.read_excel(path , na_filter=False)

This will automatically consider the empty fields as empty strings ''


If you already have the dataframe

df = df.replace(np.nan, '', regex=True)
df = df.fillna('')

Leave a Reply

The maximum upload file size: 500 MB. You can upload: image, audio, video, document, spreadsheet, interactive, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here