Privacy note: We capture your IP address to provide customised and focused services. See our Privacy Policy.

Data Science & Statistics with Python — Alpha School

Lesson 2: Types of Data and How to Collect It

Before you can analyse data, you need to know what kind of data you have, because the kind decides what you can do with it. Numbers that measure something — heights, temperatures, test scores — are quantitative, and you can add, average and compare them. Categories — favourite subject, blood group, yes or no — are categorical, and you count them rather than averaging them. Treating one kind as the other is a classic beginner error: averaging the numbers on a satisfaction scale of 1 to 5 can be useful, but averaging postcodes is nonsense, because postcodes are labels that happen to look like numbers.

Within quantitative data there is a further split. Discrete data takes whole-number values, such as the number of students in a class. Continuous data can take any value in a range, such as a person's height. And within categorical data, some categories have a natural order — small, medium, large — while others do not, such as colours. Knowing these types matters because the right chart, the right summary and the right test all depend on them.

How Data Is Collected

Data arrives in a few main ways, and each brings its own risks. A survey asks people questions directly, but people may misunderstand the question or give the answer they think is expected. An experiment changes one thing and measures the effect, which is powerful but needs care in design. Observation records what happens without interfering, as a website log does. And existing records — school registers, weather archives, public datasets — are cheap and plentiful, but they were collected for someone else's purpose and may not measure what you need.

Whatever the source, two questions matter most. Who or what is missing? A survey that only reaches the students who volunteer will not represent the whole school. And what exactly was measured? A question about "screen time" means little unless you know whether it counted phones, laptops and television together or separately. The answers to those two questions belong in every write-up, because they set the limits of what the data can say.

A Note on Measurement

Good measurement is specific, consistent and honest about its limits. If two people measuring the same thing would get different answers, the measurement is unreliable. If you measure something close to what you care about but not quite it — attendance as a stand-in for engagement, for example — say so plainly. A data scientist's job is not to pretend the measurement is perfect; it is to know how imperfect it is and to keep that in view when drawing conclusions.

When Categories Are Not Equal

Categories are not always as simple as they look. Some are ordered — small, medium, large — and the order carries information that should not be thrown away. Some are hierarchical: a country contains regions, which contain cities, and an analysis at one level may hide a pattern at another. And some categories are really numbers in disguise: a satisfaction scale from 1 to 5 looks quantitative, but the gap between 1 and 2 may not mean the same as the gap between 4 and 5, because people use the ends of a scale differently. Treating such a scale as if its steps were equal is a common shortcut, and it is usually harmless for a rough summary — but it should be a conscious choice, not an accident.

The practical rule is to look at how a variable behaves before deciding how to treat it. Plot it, count its values, and ask whether the categories have an order and whether their spacing is meaningful. If you are unsure, keep the variable as a category and count it; you can always summarise it as numbers later, but you cannot recover the categories once they have been averaged away.

Key Terms

Quantitative data
Numbers that measure something, such as heights or test scores.
Categorical data
Data that falls into categories, such as favourite subject or yes/no.
Discrete data
Quantitative data that takes whole-number values, such as a count.
Continuous data
Quantitative data that can take any value in a range, such as height.
Survey
Collecting data by asking people questions.
Experiment
Collecting data by changing one thing and measuring the effect.
Measurement
The process of assigning a value to something; it must be specific and consistent.

Discussion Questions

  1. A survey asks students to rate lunch from 1 to 5. Is that quantitative or categorical? What could go wrong with averaging the answers?
  2. A website log records every visit automatically. What is it missing that a survey might capture?
  3. Why might attendance be a poor stand-in for engagement? What would be better?

Practice Questions

  1. Give one example of quantitative data and one of categorical data.
  2. Why is averaging postcodes nonsense?
  3. What is the difference between discrete and continuous data?
  4. Name two ways data is collected, and one risk of each.
  5. A survey only reaches students who volunteer. What is the problem?
Show answers
  1. Quantitative: test scores, heights or temperatures. Categorical: favourite subject, blood group, or yes/no answers.
  2. Because postcodes are labels that happen to look like numbers — categorical data, not measurements. Their average has no meaning.
  3. Discrete data takes whole-number values, like a count of students; continuous data can take any value in a range, like height.
  4. Surveys: people may misunderstand questions or give expected answers. Experiments: they need careful design. Observation: it cannot explain why things happened. Existing records: they were collected for another purpose. Any two with a real risk count.
  5. Volunteers may differ from the whole school, so the results may not represent the population. Who is missing matters as much as who answered.
Keep reading to complete this lesson