Back to PANDAS FOR DATA ANALYTICS

Handling Missing Values

Master techniques to detect, clean, replace, or drop missing data—one of the most common real-world problems.

4 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Ready to continue?

Mark this lesson as complete when you're ready to proceed.

Key moments

  1. Basic Null Detection — The video introduces Boolean masking using the `.isnull()` and `.isna()` functions to identify standard missing values.
  2. Counting Missing Data — Learners are shown how to chain the `.sum()` method to the Boolean mask to quantify the number of nulls per column.
  3. Custom Value Detection — The `.isin()` method is demonstrated as the tool necessary to detect non-standard missing indicators defined in a custom list.
  4. Simple NaN Replacement — The `.fillna()` method is used to replace existing standard NaN values with a constant value across a column.
  5. Conditional Replacement (.mask) — The advanced `.mask()` function is introduced to perform conditional replacement based on the custom Boolean mask created by `.isin()`.
PDF notes

Frequently asked questions

What is the difference between `.isnull()` and `.isna()`?

They are identical aliases in Pandas. Both functions perform the exact same operation: returning a Boolean mask indicating standard missing values (NaN or None).

Why do I need `.isin()` if I have `.isnull()`?

`.isnull()` only detects standard Python/Numpy nulls (NaN). If your missing data is represented by strings like 'NA' or '?', you must use `.isin()` to find them.

Does `.fillna()` or `.mask()` modify the DataFrame in place?

By default, no. To modify the original DataFrame directly, you must either assign the result back (e.g., `df = df.fillna(0)`) or use the `inplace=True` argument.

What happens if I chain `.sum().sum()`?

The first `.sum()` counts nulls per column (Series). The second `.sum()` sums those column totals together, giving you the grand total of all missing cells in the DataFrame.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.