Pandas DataFrame.fillna()We can use the fillna() function to fill the null values in the dataset. Syntax:Parameters:
Returns:It returns an object in which the missing values are being filled. Example1:Output x 0 10.0 1 20.0 2 30.0 3 40.0 4 50.0 5 NaN x 0 10.0 1 20.0 2 30.0 3 40.0 4 50.0 5 0.0 Example2:The below code is responsible for filling the DataFrame that consist some NaN values. Output A B C D 0 NaN NaN 20.0 0 1 1.0 NaN 4.0 1 2 NaN NaN NaN 5 3 NaN 20.0 NaN 2 Example3:In below code, we have used the fillna function to fill in some of the NaN values only. Output A B C D 0 0.0 1.0 20.0 0 1 1.0 NaN 4.0 1 2 NaN NaN 2.0 5 3 NaN 20.0 NaN 2 Next TopicDataFrame.replace() |