Log inStart free
LESSON 4.08 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Missing values and outliers

Watch two empty cells and five outliers bend 40 points, then repair both.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 4.08 · CLEANING BAY2 NaN CELLS · 40 ROWS
01
Stage 1 of 6 · Missing cells
Points 7 and 22 have no x₁: each cell is NaN, a missing value. A dashed line marks each one.
Explain it simply

The table holds 40 points, each with an x₁ and an x₂. 2 x₁ cells are empty, and pandas stores NaN there: not a number. You still know x₂, so each of those points is a dashed line at its height. Here the cells went missing at random, so the rest of the column still tells the truth.

40 points on a plane. x₁ of points 7 and 22 is NaN, so each is a dashed line at its known x₂. 38 x₁ values and 40 x₂ values are left.

pointpoint with a NaN cellmean, quartiles, filled valuefencesflagged outlier
−3−2−101234−3−2−10123x₁x₂7223637383940dense · 24sparse · 11pointx₁x₂7NaN−0.6622NaN−0.52364.20−2.1037−3.102.3038−2.90−2.50390.602.6040−0.10−1.60values3840NaN20rows 7, 22, 36–40each column40 points · x₁ of 7 and 22 is NaNx₁: 38 values, 2 NaN (points 7, 22) · x₂: 40 values, 0 NaN−3−2−101234−3−2−10123x₁x₂7223637383940dense · 24sparse · 11pointx₁x₂7NaN−0.6622NaN−0.52364.20−2.1037−3.102.3038−2.90−2.50390.602.6040−0.10−1.60values3840NaN20rows 7, 22, 36–40each column40 points · x₁ of 7 and 22 is NaNx₁: 38 values, 2 NaN (points 7, 22) · x₂: 40 values, 0 NaN
Toy: the 4.C5 toy · 40 points · x₁ of 7 and 22 NaN · outliers 36–40
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
nj=n−nNaN,j\sy{nobs}{data}{n_j} = \sy{n}{ink}{n} - \sy{nan}{ink}{n_{\text{NaN},j}}
n1=40−2=38,n2=40−0=40n_1 = 40 - 2 = 38,\quad n_2 = 40 - 0 = 40

Each column keeps every cell that is not NaN.

Common mix-ups

MYTHA point with |z| under 3 is not an outlier.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01Does the rule |z| > 2 flag point 39?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.