liveBook · Manning

Missing value

As explained in Starting Data Analytics with Generative AI and Python

A missing value is an absent or unavailable data value in a record or variable.

A missing value is a piece of information absent from a record. Before using a dataset to answer a business question, check where values are missing: an empty field may reflect an error, a failed measurement, or information that was never available. Treating all three cases alike can make an analysis unreliable. section 2.5.2 section 2.4.1

df.isna().sum()

Run `df.isna().sum()` to count missing values by column. Also inspect `df.info()` for non-null counts. These checks overlap, so choose the output that makes the problem easiest to see. section 2.3

Counts are a starting point, not a cleaning rule. Inspect affected records and ask why the information is absent. Missing order approval or delivery dates, for example, call for examining the order process and the relationship between dates and order status. section 2.5.2

Choose a response based on the amount of missing data and what each field means:

  • Delete an incomplete row or column when losing it is appropriate. section 2.5.2
  • Ignore a missing field when the analysis does not require it. section 2.5.2
  • Fill a field with a default, an estimate such as a mean, median, or mode, or an interpolated value—but check whether that choice makes sense for the data. section 2.5.2

A fill that looked convenient but was wrong

A country dataset had missing entries filled by copying adjacent cells. Because the rows were sorted alphabetically by country name, neighboring values had no sound relationship to the missing ones. A filled table is not necessarily a more accurate table. section 2.5.2

Missing values belong in the broader data-cleaning check alongside duplicates, entry errors, and validation. Inspect the raw records and the data-collection process before accepting a proposed fix, including one suggested by an AI assistant. section 2.4.1 section 2.5.2

How Starting Data Analytics with Generative AI and Python covers it

How deep it goes
Explains possible causes and choices among deletion, ignoring, and filling, without prescribing one replacement rule.
Examples
Examines missing order dates and product details, and warns against copying values across alphabetically sorted country records.
What it assumes
Assumes a loaded pandas DataFrame for the demonstrated checks and introduces the missing-value decisions in plain terms.
What you can do after
Diagnose/debug with it by counting missing entries, inspecting affected records, and selecting a response suited to their meaning.
How it connects
Connects missing values to data cleaning, data validation, data integration, and sensor errors.

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 Starting Data Analytics with Generative AI and Python. The section links point to the parts of the book it draws on.