Kinds of data
Categories: labels, not amounts
A category puts each row into a group; you cannot add or average categories, but you can count how many rows fall in each group.
By the end of this lesson you can spot a category column and explain why you cannot average "favourite fruit".
Why it matters
A school planning a new bus needs to know how many pupils come by bus. That answer comes from a column of words: Bus, Car, Walk. Words are some of the most useful data there is, once you know how to count them.
The idea in plain words
Think of sorting laundry into piles: whites, colours, darks. Each piece of clothing goes into exactly one pile. The piles have names, not amounts.
Some columns work the same way. Lucía's travel_mode column puts every pupil into one pile: Bus, Bicycle, Car or Walk. A column like this is called a category.
Category: a group that a row belongs to, given by a label such as Bus or Mango. A category column holds labels, not amounts.
Each pupil lands in exactly one pile. Nobody in class 5A walks, so there is no Walk pile here.
You cannot do sums with categories. What is Bus + Car? What is the average of Mango and Guava? These questions have no answer. But you can count how many rows are in each pile. That count is a number, and you can work with it.
See it done
Data:
class-survey.csv(synthetic), class 5A only: sheet rows 2 to 16.
Question: what is the most common way to get to school in class 5A?
- Check it is a category.
travel_modeholds labels: Bus, Bicycle, Car, Walk. Yes. - List the groups. Bus, Bicycle, Car, Walk.
- Tally. Go down rows 2 to 16, one pupil at a time. For each pupil, make one mark next to their group.
- Count the marks. Bus 9, Bicycle 3, Car 3, Walk 0.
- Check the total. 9 + 3 + 3 + 0 = 15. Class 5A has 15 pupils, so every pupil was counted once.
- Answer. The bus. 9 of the 15 pupils in 5A come by bus.
Counting the labels turns words into numbers you can compare.
Tip: step 5 is a habit worth keeping. If your group counts do not add up to the number of rows, you missed someone or counted someone twice.
Your turn, with help
Now do class 5B: sheet rows 17 to 31. Tally travel_mode.
Hint: 5B also has 15 pupils, so your four counts must add up to 15.
Show the answer
Bus 5, Car 5, Walk 4, Bicycle 1. Total 5 + 5 + 4 + 1 = 15. In 5B, bus and car are tied as the most common.
Your turn, alone
- Which of these columns in Lucía's table are categories?
class,travel_minutes,favourite_fruit,siblings,travel_mode. - Use your two tallies. How many pupils in both classes (5A and 5B together) come by bus?
- A friend says, "The average favourite fruit is Orange." What is wrong with this?
- Name two columns in Amara's sheet that are categories you could tally.
Check your answers
class,favourite_fruitandtravel_mode.- 9 + 5 = 14 pupils.
- You cannot average labels. You could say which fruit is the most common, by counting.
- Any two of
fruit,paymentandday.
Watch out
- Doing sums with labels. If a sum or an average of words seems possible, stop. Count the groups instead.
- Spelling the same group two ways. "Bus", "bus" and "BUS " look the same to you, but a computer may treat them as three groups. Keep labels identical.
- Forgetting the empty groups. Walk had 0 pupils in 5A. Zero is still an answer worth reporting.
Say it back
- What is a category?
- Can you average a category column?
- What can you do with a category column instead?
Show the answers
- A group that a row belongs to, given by a label.
- No.
- Count how many rows fall in each group.
What is next
Some categories hide a secret: an order. Small, medium, large. If you sort them A to Z, something odd happens. Next lesson.