Data is everywhere
Columns and variables: what we notice about each thing
A column asks one question of every row; the thing it measures is called a variable because its answer can vary.
By the end of this lesson you can name the variables in a table and explain why they are called variables.
Why it matters
When someone asks "which fruit sells best?", you need to know where in the table the fruit lives. Every question you will ever ask a table is answered by its columns. Know the columns, and you know what the table can tell you.
The idea in plain words
Think of a form at a clinic. It asks every patient the same questions: name, age, reason for visit. Each patient gives their own answers.
A table is like a pile of those forms, laid out flat. Each question becomes a line going down. That line down is called a column. Each patient's answers become a row going across.
Column: one line down a table. It holds the answer to the same question for every row.
In Amara's table, the fruit column asks every sale, "Which fruit was sold?" The quantity column asks, "How many?" The payment column asks, "How did the customer pay?"
Each column asks one question. Every row gives its own answer.
Now the new word. The answer to "which fruit?" is not the same every time. It varies: banana, then pineapple, then pawpaw. So the thing in a column gets a special name. It is called a variable.
Variable: something we record about every row, whose value can change from one row to the next. Fruit, quantity and payment are variables.
In everyday talk, "column" and "variable" mean almost the same. The column is the place on the page. The variable is the thing it records.
See it done
Question: what are the variables in Amara's table, and what does each one ask?
Data:
market-stall-week.csv(synthetic). It has 8 columns.
- Read the top line. The column names are:
sale_id,date,day,time,fruit,quantity,price_each_naira,payment. - Turn each name into a question.
| Column | The question it asks every sale |
|---|---|
sale_id |
What is this sale's name tag? (S001, S002 ...) |
date |
On which date? |
day |
On which day of the week? |
time |
At what time? |
fruit |
Which fruit? |
quantity |
How many? |
price_each_naira |
What does one fruit cost, in naira (₦)? |
payment |
How did the customer pay? |
- Count them. 8 columns, so Amara records 8 variables about every sale.
- Check that they vary. Look only at the 9 Tuesday rows. Six columns change from row to row. Two columns,
dateandday, are the same on every Tuesday row, because all nine sales happened on the same day.
date and day stay the same on Tuesday. Across the whole week they change, so they are still variables.
Your turn, with help
Lucía, a teacher in Bogotá, Colombia, wants to make a table about her class. She asks every pupil three questions:
- How old are you?
- What is your favourite fruit?
- How do you get to school?
- What is one row in Lucía's table?
- What three columns will she need? Give each a short name.
Hint: one row is the "one thing" she asks the questions to. Each question becomes one column.
Show the answer
- One pupil.
- Three columns, for example
age,favourite_fruitandtravel_mode. Any clear short names are fine.
Your turn, alone
- In Amara's table, which column answers the question "How many?"
- Write the question that the
paymentcolumn asks. - Look back at your own table from lesson 1.1. List your columns. Is each one a variable? (Does its value change from one row to another?)
- A weather table has one row per day and these columns:
date,rain_mm,hottest_temp_c. How many variables does it record about each day?
Check your answers
quantity.- "How did the customer pay?"
- Your own answer. Most columns will be variables. If one column had the same value on every line, it is still a variable: it could have changed, it just did not this time.
- 3 variables.
Watch out
- Mixing up rows and columns. Rows go across (like a row of seats). Columns go down (like the columns holding up a building).
- Vague column names. A column called
numbercould mean anything.quantityorprice_each_nairatells you exactly what is inside. - Two questions in one column. A column called
fruit_and_quantitywith "Pawpaw 4" mixes two variables. Split it into two columns.
Say it back
- What is a column?
- Why is it called a variable?
- Amara's table has how many variables?
Show the answers
- One line down a table, holding the answer to the same question for every row.
- Because its value can change (vary) from one row to the next.
- 8.
What is next
You now know rows go across and columns go down. So where exactly does "Pawpaw" live? Spreadsheets give every single box an address, a bit like a seat number at a stadium. Next lesson.