liveBook · Manning

Missing value

As explained in Pandas Workout: 200 exercises to make you a stronger data analyst

A missing or null value is an absent or unavailable observation or field in a dataset.

A missing value marks an observation or field that was never collected, became unavailable, or cannot be used as recorded. In pandas, missing data is commonly represented by NaN rather than 0, because zero can be a meaningful measurement. NaN is a floating-point value that cannot become an integer and is not equal to itself. section 2.20

Handle missing values by matching the cleaning rule to the analytical question:

  • Remove rows containing any NaN with dropna(); this is simple but can discard every row when each row has one missing field. section 5.2
  • Require completeness only in decision-critical columns by passing their names through dropna(subset=[...]). section 5.1 section 5.2
  • Allow limited gaps with thresh, which keeps rows containing at least a specified number of non-null values. section 5.4

Parking-ticket cleanup

Load selected columns from the NYC parking-violations CSV, count rows with len(df.index), and compare several policies. First, remove every incomplete row with df.dropna(). Then retain rows only when Plate ID, Registration State, Vehicle Make, and Street Name are present. Finally, relax the rule by omitting Vehicle Make. Subtract the retained-row count from the original count and multiply by $100 to estimate the potential cost of dismissible tickets. Test a further variation with thresh=3, and convert BLANKPLATE into NaN before rerunning the analysis. section 5.1 section 5.2 section 5.4

df = df.dropna().copy()

Use df.dropna().copy() when you need a separate, fully non-null data frame for further analysis. section 2.20

How Pandas Workout: 200 exercises to make you a stronger data analyst covers it

How deep it goes
Explains NaN representation and row filtering, then extends to column subsets and minimum non-null thresholds.
Examples
Uses NYC parking violations, ticket-dismissal policies, BLANKPLATE normalization, and completeness thresholds as working examples.
What it assumes
Assumes familiarity with pandas data frames, columns, indexes, and CSV loading while teaching missing-data decisions through a concrete task.
What you can do after
Apply pandas dropna, subset, and thresh rules to measure and clean incomplete records.
How it connects
Connects missing values with pandas, data cleaning, null values, row filtering, and interpolation.

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 Pandas Workout: 200 exercises to make you a stronger data analyst. The section links point to the parts of the book it draws on.