Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Data Cleanup  ›  Lesson

Handling Missing Data

Handling Missing Data 14 minBefore filling or dropping a missing value, find out why it is missing, because the reason decides which fix is honest.

Handling Missing Data

June's orders export has a few holes: some amounts are blank, one customer name is empty, and a whole afternoon has no rows at all. Every analysis tool has a default way of handling blanks, and none of them knows why the value is missing. You do, or you can find out. That reason decides the fix.

The rule

Ask why it's missing before deciding how to fill it.

Missing values come from different places, and each points to a different fix:

  • It can be worked out from other columns. An amount is missing but the item and quantity are there: amount = price × qty. Recalculate it.
  • It was never recorded, for no particular reason. A few customer names skipped at a busy till. Leave them blank, or label them Unknown, and move on.
  • It is missing for a reason that matters. The card machine failed, so an afternoon's card orders were never logged. Filling or dropping hides a real gap; report it instead.
  • It really is zero or "none". A day the café was closed has no sales. A blank there should be an explicit 0 or closed, depending on the question.

Then choose an action:

action when it fits risk
Recalculate the value follows from other columns none, if the rule is right
Drop the row few rows, missing at random shrinks data; can bias results
Fill with median or mode a small number of gaps in a column makes data look more certain than it is
Flag and keep always, alongside any fix none

Whatever you do, add a flag column such as amount_filled = yes, so anyone can see which values are original.

The shortcut

Count before you fix: how many are missing, where, and do they cluster? A handful scattered at random is a small problem. Many bunched on one day, one till or one item is a story.

Three blank amountsStep 1 of 4
  1. Count and locate

    Three orders out of 400 have no amount: 1011, 1027 and 1043.

The trap is the blanket fill: replacing every gap with the column average. It invents values that nobody ordered and hides patterns you should have spotted.

Drills

Answer fast — trust the rule.

quick drill

An order has qty 3 and item C02 (₹40) but no amount. What is the best fill?

quick drill

Every card order between 2 pm and 5 pm on 14 June is missing. What should you do first?

quick drill

A column of delivery times has 2 blanks among 200 values, and it is skewed by a few very slow deliveries. If you must fill, which value is safest?

quick drill

Why add a flag column like amount_filled?

Remember

  • Ask why it's missing before deciding how to fill it.
  • Shortcut: count, locate, look for clusters; recalculate when you can.
  • Trap: blanket-filling with the average invents data; always flag what you filled.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainThree missing amounts

Three orders in the sheet have no amount, but each has an item code and a quantity. Explain how you would handle them, and why filling them with the column average would be a poor choice here.