Replace NaN with Blank or Empty String in Pandas? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In this article, we will discuss how to replace NaN with Blank or Empty string in Pandas. Example: Input: "name": ['suraj', 'NaN', 'harsha', 'NaN'] Output: "name": ['sravan', , 'harsha', ' '] Explanation: Here, we replaced NaN with empty string.Replace NaN with Empty String using replace() We can replace the NaN with an empty string using df.replace() function. This function will replace an empty string inplace of the NaN value. Python3 # import pandas module import pandas as pd # import numpy module import numpy as np # create dataframe with 3 columns data = pd.DataFrame({ "name": ['sravan', np.nan, 'harsha', 'ramya'], "subjects": [np.nan, 'java', np.nan, 'html/php'], "marks": [98, np.nan, np.nan, np.nan] }) # replace nan with empty string # using replace() function data.replace(np.nan, '') Output: Replace NaN with Blank String using fillna() The fillna() is used to replace multiple columns of NaN values with an empty string. we can also use fillna() directly without specifying columns. Example 1: Multiple Columns Replace Empty String without specifying columns name. Python3 # import pandas module import pandas as pd # import numpy module import numpy as np # create dataframe with 3 columns data = pd.DataFrame({ "name": ['sravan', np.nan, 'harsha', 'ramya'], "subjects": [np.nan, 'java', np.nan, 'html/php'], "marks": [98, np.nan, np.nan, np.nan] }) # replace nan with empty string # using fillna() function data.fillna('') Output: Example 2: Multiple Columns Replace Empty String by specifying column name. Python3 # import pandas module import pandas as pd # import numpy module import numpy as np # create dataframe with 3 columns data = pd.DataFrame({ "name": ['sravan', np.nan, 'harsha', 'ramya'], "subjects": [np.nan, 'java', np.nan, 'html/php'], "marks": [98, np.nan, np.nan, np.nan] }) # replace nan with empty string # using fillna() function data[['name', 'subjects', 'marks']].fillna('') Output: RECOMMENDED ARTICLES - Check for NaN in Pandas DataFrame Comment More infoAdvertise with us Next Article Replace Characters in Strings in Pandas DataFrame S sravankumar_171fa07058 Follow Improve Article Tags : Python Python-pandas Python pandas-dataFrame pandas-dataframe-program Practice Tags : python Similar Reads Replace NaN Values with Zeros in Pandas DataFrame NaN stands for Not A Number and is one of the common ways to represent the missing value in the data. It is a special floating-point value and cannot be converted to any other type than float. NaN value is one of the major problems in Data Analysis. It is very essential to deal with NaN in order to 5 min read Replace NaN Values with Zeros in Pandas DataFrame NaN stands for Not A Number and is one of the common ways to represent the missing value in the data. It is a special floating-point value and cannot be converted to any other type than float. NaN value is one of the major problems in Data Analysis. It is very essential to deal with NaN in order to 5 min read Replacing Pandas or Numpy Nan with a None to use with MysqlDB The widely used relational database management system is known as MysqlDB. The MysqlDB doesn't understand and accept the value of 'Nan', thus there is a need to convert the 'Nan' value coming from Pandas or Numpy to 'None'. In this article, we will see how we can replace Pandas or Numpy 'Nan' with a 3 min read Replace Characters in Strings in Pandas DataFrame In this article, we are going to see how to replace characters in strings in pandas dataframe using Python. We can replace characters using str.replace() method is basically replacing an existing string or character in a string with a new one. we can replace characters in strings is for the entire 3 min read How to Replace Numpy NAN with String Dealing with missing or undefined data is a common challenge in data science and programming. In the realm of numerical computing in Python, the NumPy library is a powerhouse, offering versatile tools for handling arrays and matrices. However, when NaN (not a number) values appear in your data, you 2 min read Replace all the NaN values with Zero's in a column of a Pandas dataframe Replacing the NaN or the null values in  a dataframe can be easily performed using a single line DataFrame.fillna() and DataFrame.replace() method. We will discuss these methods along with an example demonstrating how to use it.                            DataFrame.fillna() 3 min read Like