Menu

Checking for Missing Values

Checking for Missing Values

Before training a machine learning model, it is important to verify whether the dataset contains any missing values. Missing data can lead to errors during preprocessing or reduce the model's performance.

We will use the isnull() function to identify any empty cells in the dataset.

Code

# Check for missing values
df.isnull().sum()

Remove Missing Values (Optional)

If your dataset contains missing values, you can remove them using:

df.dropna(inplace=True)

Verify Again

df.isnull().sum()