liveBook · Manning

Missing value

As explained in Grokking Machine Learning

A missing value is an absent, unreadable, or otherwise unavailable entry in a dataset.

What should happen when a dataset has no cabin number, age, or port for a passenger? A missing value is an absent, unreadable, or unavailable entry, often represented as NaN. Leaving these entries untreated can cause model-fitting errors. section 13.2

Clean missing values by making a column-by-column decision:

  • Count missing entries with is_na (or is_null), which returns 1 for NaN and 0 otherwise. section 13.2
  • Drop a column when too many values are missing; the Titanic Cabin column is removed. section 13.2
  • Fill numerical gaps such as Age with the column median, and fill categorical gaps such as Embarked with U. section 13.2
  • Save the cleaned dataset before using it for modeling. section 13.2
raw_data.isna().sum()
Output:
PassengerId    0
Survived       0
Pclass         0
Name           0
Sex            0
Age          177
SibSp          0
Parch          0
Ticket         0
Fare           0
Cabin        687
Embarked       2

Inspect missing-value counts across every Titanic dataset column before choosing whether to remove or fill entries. section 13.2

How Grokking Machine Learning covers it

How deep it goes
Explains detection, column removal, and simple numerical or categorical replacement without developing missingness theory.
Examples
Uses Titanic Cabin, Age, and Embarked columns to demonstrate counting, dropping, median filling, and category filling.
What it assumes
Assumes familiarity with DataFrames and basic datasets while introducing practical cleanup decisions.
What you can do after
Apply Pandas checks and replacement methods to prepare a dataset for modeling.
How it connects
Connects missing values to DataFrames, dataset cleaning, numerical features, categorical features, and machine-learning models.

Also explained in

Compare how 35 books explain missing value →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning. The section links point to the parts of the book it draws on.