liveBook · Manning

Missing value

As explained in Statistics Every Programmer Needs

A null value is a missing or undefined data value represented as having no usable value.

A missing value is an undefined or unusable data value. In numerical data, NaN can represent an undefined result or a value that does not apply to an observation. section 6.2.2

Handling missing values is part of data wrangling: inspect their presence, determine what the value means, and prepare the data before modeling or analysis. section 6.2.2 section 7.2.2

A practical workflow includes:

  • Inspect non-null counts and data types with pandas DataFrame.info(). section 7.2.2
  • Interpret whether NaN means an undefined result, an inapplicable observation, or a value requiring correction. section 6.2.2
  • Replace missing values only when the domain meaning supports a specific replacement. section 6.2.2

Replacing missing yards gained

For fourth-down run and pass plays, NaN in YARDS_GAINED represents plays that gained no yards, so pandas can replace it with zero: nfl_pbp['YARDS_GAINED'] = nfl_pbp['YARDS_GAINED'].fillna(0). section 6.2.2

How Statistics Every Programmer Needs covers it

How deep it goes
Explains NaN semantics, inspection with info(), and fillna() replacement, but does not develop broader imputation methods.
Examples
Uses NFL play-by-play YARDS_GAINED values and Apple stock-price null-count inspection as concrete examples.
What it assumes
Assumes familiarity with pandas data frames and treats data wrangling as preparation before modeling or analysis.
What you can do after
Apply it via pandas to inspect null counts and replace semantically appropriate NaN values before analysis.
How it connects
Connects missing values with data wrangling, pandas data frames, preprocessing, decision trees, and random forests.

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 Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.