Sitemap
Harrygurjar

Harrygurjar

We are here to Help Each Other. Proud to be part of the medium community.

Missing Data, Missing Data, Missing Data

2 min readAug 9, 2022
“Missing data decide quality of our insights”

How do work with Missing Data?

how do we identify all those missing values and deal with them?

Steps for working with missing data:

Identify missing data

Deal with missing data

Correct data format

Missing data could be found like ‘?’,0, or Nan (not a number) especially in pandas we need to convert missing values into NaN So how can we do that is just by using replace function(),

import numpy as np
df.replace(“?”,np.nan,inplace=True)
df.head(5)

The missing values are converted by default. We use the following functions to identify these missing values. There are two methods to detect missing data

  1. .isnull()
  2. .notnull()

Count missing values in each column,

Get Harrygurjar’s stories in your inbox

Join Medium for free to get updates from this writer.

Using a for loop in Python, we can quickly figure out the number of missing values in each column. As mentioned above, “True” represents a missing value and “False” means the value is present in the dataset. In the body of the for loop the method “.value_counts()” counts the number of “True” values.

How to deal with missing data? following steps need to take either

  1. Drop data
    a. Drop the whole row
    b. Drop the whole column
  2. Replace data
    a. Replace it by mean
    b. Replace it with frequency
    c. Replace it based on other functions

Whole columns should be dropped only if most entries in the column are empty We have some freedom in choosing which method to replace data; however, some methods may seem more reasonable than others. We will apply each method to many different columns

a.Replace it by mean: here we are replacing the missing value with the average of columns like

df[“normalized-losses”].replace(np.nan,avg_normal_loss,inplace=True)

b. Replace it with frequency: here we are replacing the missing value with the mode of columns like a value that occurs most frequently in column

There are many other crucial steps we need to take for improving data quality

here, I did DATA WRANGLING like involve all major steps

Data Cleaning

Data Standardization

Data Normalization

Binning etc

have look at my Kaggle notebook, To learn more about Data analytics follow me here . I am sharing my learning here

--

--

Harrygurjar
Harrygurjar

Written by Harrygurjar

We are here to Help Each Other. Proud to be part of the medium community.