Acquiring and preparing data
Row 14: a box of Delicious sold for ₹9,000. That's ₹900 a kilo. Apples aren't saffron.
- Hunt impossible values, mixed units and bad labels
- Keep a change log
- Know when to leave data out
Acquiring and preparing data
Row 14: a box of Delicious sold for ₹9,000. That's ₹900 a kilo. Apples aren't saffron.
- Hunt impossible values, mixed units and bad labels
- Keep a change log
- Know when to leave data out
Story
Learn it
Before any analysis, data has to be acquired and prepared, and the worst mistakes hide in plain sight. ₹9,000 for a box of apples is ₹900 a kilogram: that is not a price, it is a mistake, and a prediction built on it is wrong before it starts. Pre-processing hunts three new kinds of fault, and a change log records every decision, so anyone (including you, next month) can check it.
Words to know
getting data. Four ways: measure it yourself, ask people (a survey), observe and record, or use existing records.
everything you do to data before analysing it.
a number that cannot be true, like ₹900 a kilo for apples. Check numbers against what you already know.
some rows per kilogram, others per box. The column still adds up, and the answer means nothing.
Delicious, delicious and Dilicious are one variety to a person and three to a machine.
a table of every change: row · what was wrong · what we did · why.
Step by step: cleaning five rows of a walnut price list
| Row | Variety | Price | Unit |
|---|---|---|---|
| 1 | Kagzi | 700 | kg |
| 2 | kagzi | 7000 | kg |
| 3 | Burzul | 5500 | box |
| 4 | Burzul | 550 | kg |
| 5 | Wonth | 400 | (blank) |
- Save a copy first. Never clean the only copy.
- Impossible value: row 2, ₹7,000 a kilo, is ten times row 1. Probably a typing slip; we can't know, so mark it and leave it out.
- Mixed units: row 3 is per box (10 kg). Convert: 5,500 ÷ 10 = ₹550 a kilo, matching row 4.
- Inconsistent labels: change
kagzitoKagzi. - Missing unit: row 5 could be per kilo or per box. Mark it unknown and leave it out. Never guess.
- Log every change, and count: 5 rows at the start, 2 changed, 2 left out, 3 you trust.
Acquire well: name the source, get permission when the data is about people, record when and how it was collected, and don't collect only the easy cases.
🕌 From our heritage
Ibn Khaldūn (1332–1406) opened his Muqaddimah by attacking historians who repeated impossible numbers. One chronicle gave an ancient army as six hundred thousand men; he answered that a far larger empire could barely field a fraction of that, and that a state that size would have left traces nobody can find. His rule was that in reports of money and troop numbers, "exaggeration is to be expected", so a figure must be tested against what we know of the world and against the rules of probability. That is precisely the test Hiba ran on ₹9,000 a box.
Source: Ibn Khaldūn, al-Muqaddimah (1377), on the criticism of historical reports.
Careful: an impossible value is not the same as an outlier. An outlier is real but unusual, and you keep it; ₹9,000 for a box cannot be what the column says. And never work out a missing unit from the size of the number: that is guessing dressed up as reasoning.
Your missions
mandi-prices-messy.ods · change-log.odsCopy first
1 min- 1
Open
mandi-prices-messy.odsand immediately save a copy with your roll numbers. Never clean the only copy.
Hunt three kinds of fault
13 minin pairs- 2
Predict: how many rows will you have to change or remove? Write a number.
Only you can see this - 3
Impossible values: sort by
Price, descending. For each suspect, ask what is that per kilogram? - 4
Mixed units: use the
Unitcolumn. Convert per-kg rows to per-box at 10 kg a box. If a row has no unit, mark itunknownand leave it out — don't guess. - 5
Inconsistent labels: Data → AutoFilter on
Variety. Choose one spelling for each and fix the rest. - 6
Log every change in
change-log.ods: Row · What was wrong · What we did · Why.
Count and ask
4 min- 7
Write: rows at the start · changed · removed · rows you trust. Then the one question you'd ask the mandi clerk.
Find a price that is possible but suspicious. What would it take to trust it?
No laptop today?
Mark the twelve-row printed table with I (impossible), U (unit), L (label), then rewrite it cleanly with a four-column change log beside it.
Debate it
Your pair removed nine rows, including four where the unit was missing. A classmate says: "Now your data is smaller, so your answer is worse."
Is a smaller, trustworthy dataset worse than a bigger one with mistakes in it? When would each answer be right?
Check yourself · practice, not a test
In the app, students answer these one at a time and each answer is checked straight away. It's practice, never a mark — anything they miss comes back later for another go.
1.Put these pre-processing steps in a sensible order:
- 1Fix mixed units and inconsistent labels
- 2Find impossible values and check them against what you know
- 3Record every change in the change log
- 4Save a copy of the original
2.A row gives a price but no unit. The honest thing is to:
- AAssume it is per box, like most rows
- BAssume it is per kilogram, to be safe
- CMark it unknown and leave it out of the analysis
- DDelete it silently
3.Delicious and delicious count as the same variety when a machine groups the rows.
TrueFalse4.Which are ways of acquiring data? (choose all that apply)
- AMeasuring it yourself
- BAsking people in a survey
- CObserving and recording
- DUsing records someone already keeps
- EEstimating what it probably was
5.A ______ log records what was wrong, what you did and why — so that somebody else can check your cleaning.
Cleaning is not tidying. Every change gets a reason, and a line in the log.
Typing practice
Skill: brackets and quotes, in pairs (Term 1 focus, 5 min)
-
On typing.com, continue the symbols lessons.
-
Then type each of these five times. Every one is a formula you will use today:
=COUNTIF(C2:C40;"Delicious") -
Brackets and quotation marks always come in pairs. Train the pair as one movement: open, type, close. Depending on the laptop's language setting the separator is
;or,.
- =COUNTIF(C2:C40;"Delicious")
- ;
- ,
Written and designed by Faizan Ayoub. © 2026 Faizan Ayoub. All rights reserved.