{"id":3816,"date":"2021-04-27T19:37:56","date_gmt":"2021-04-27T14:07:56","guid":{"rendered":"https:\/\/python-programs.com\/?p=3816"},"modified":"2021-11-22T18:53:44","modified_gmt":"2021-11-22T13:23:44","slug":"pandas-replace-nan-with-mean-or-average-in-dataframe-using-fillna","status":"publish","type":"post","link":"https:\/\/python-programs.com\/pandas-replace-nan-with-mean-or-average-in-dataframe-using-fillna\/","title":{"rendered":"Pandas: Replace NaN with mean or average in Dataframe using fillna()"},"content":{"rendered":"

In this article, we will discuss the replacement of NaN values with a mean of the values in rows and columns using two functions: fillna() and mean().<\/p>\n

In data analytics, we have a large dataset in which values are missing and we have to fill those values to continue the analysis more accurately.<\/p>\n

Python provides the built-in methods to rectify the NaN values or missing values for cleaner data set.<\/p>\n

These functions are:<\/p>\n

Dataframe.fillna():<\/h2>\n

This method is used to replace the NaN in the data frame.<\/p>\n

The mean() method:<\/h3>\n
mean<\/span>(<\/span>axis=<\/span>None<\/span>, skipna=<\/span>None<\/span>, level=<\/span>None<\/span>, numeric_only=<\/span>None<\/span>, **kwargs<\/span>)\r\n<\/span><\/pre>\n

Parameters::<\/p>\n