Ticker

6/recent/ticker-posts

Handling missing values :

 Handling missing values :

Techniques to fill missing values (Data Imputation):

Importing the libraries:


 

Loading the titanic dataset:

 
Printing first five rows:


 

To find number of rows and columns:

 


Overall information about the dataset:


 

Finding missing values:

 


Visualizing the null values using heatmap:

 


Method:1
1) Deleting the rows with missing values

Deleting the body, cabin, home.dest, boat columns:

 

Method:2
2) Filling with mean or median or mode value

Filling NaN with mean value in the age column:


Filling NaN with median value in the age column:


 
Filling NaN with mode value in the age column:



Method:3
3) Replacing with previous(forward fill) or next value(backward fill)

Filling values with previous value (Forward fill):



 
Filling values with next value(Backward fill):



 

Method : 4
4) Filling with a single value

Filling NaN with single value=30:


 

Method : 5
5) Interpolation method

Filling NaN with interpolate method:



 





x

Post a Comment

0 Comments