How to Replace NaN with Blank Empty String in Pandas?

Spread the love

Problem –

You want to replace Nan with blank empty string in pandas.

Solution –

Let’s read a dataset to work with.

import pandas as pd

url = 'https://raw.githubusercontent.com/bprasad26/lwd/master/data/fruit_prices.csv'
df = pd.read_csv(url)
df.head()

We can see that we have some NaN values here. To fill these NaN values with blank empty string we can use the fillna() method in pandas.

df.fillna('', inplace=True)

Related Posts –

  1. Pandas – fillna() method – Handle Missing values in Python

Rating: 1 out of 5.

Leave a Reply