Saltar al contenido

Lección 3 · Kinds of Data

Types of Data: Categorical and Numeric

Tell categorical from numeric data, nominal from ordinal and discrete from continuous, learn the four measurement levels and which summaries fit each one.

Not every number behaves like a number, and not every piece of data is a number. The type of a variable decides which calculations make sense and which charts work. If you average phone numbers or subtract postal codes, a computer will happily give you an answer, and the answer will be nonsense. This lesson helps you avoid that.

Two big families

Categorical: groups

Nominal No natural order
Ordinal Ordered groups
1 / 2

Categorical (or qualitative) data places each observation in a group. Numeric (or quantitative) data records an amount that you can do arithmetic with.

Nominal and ordinal

  • Nominal categories have names but no order: eye color, country, payment method, blood group.
  • Ordinal categories have a natural order, but the gaps between them are not known to be equal: small, medium, large; or "disagree, neutral, agree"; or finishing places 1st, 2nd, 3rd.

In a race, 1st might beat 2nd by one second, while 2nd beats 3rd by a minute. The places show order, not distance.

Discrete and continuous

  • Discrete data takes separate values, usually from counting: number of children, calls per day, defects per box.
  • Continuous data can take any value in a range, usually from measuring: height, time, temperature, weight. In practice we round it, but the underlying quantity is continuous.

A binary (or Boolean) variable has just two values, such as yes and no. It is categorical, and counting the share of "yes" is a very common summary.

Numbers that are really labels

Some columns contain digits but are categories:

  • postal codes and phone numbers;
  • student or product ID numbers;
  • jersey numbers on sports shirts;
  • codes such as 1 = bus, 2 = train, 3 = bike.

Ask: does adding two of these produce anything meaningful? If not, treat the column as a category. It is also wise to store such codes as text so that leading zeros are not lost. A code like 00725 becomes 725 if software reads it as a number.

Python Why averaging codes is nonsense

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The program calculates an average near 2, which looks like "train", although nobody took the train. Counts and shares are the right summary.

Four levels of measurement

A common way to sort variables uses four levels of measurement. Each level allows everything the one before it allows, plus something more.

Level What you can say Example Typical summaries
Nominal same or different blood group counts, mode
Ordinal also order shirt size counts, mode, median
Interval also equal gaps temperature in Celsius mean, differences
Ratio also a true zero weight, price mean, differences, ratios

The difference between interval and ratio is the true zero. A weight of 0 kg means no weight, so 20 kg is twice as heavy as 10 kg. But 0 degrees Celsius does not mean "no temperature". So 20 degrees Celsius is not twice as hot as 10 degrees. Calendar years are also interval: the year 2000 is not "twice" the year 1000 in any useful sense.

Ratings are tricky

Star ratings and agreement scales are ordinal. People often average them anyway, because an average is convenient. This can be acceptable as a rough indicator, but remember that it assumes the step from 1 to 2 stars means the same as from 4 to 5. A safer report also shows the distribution: how many people chose each option.

Two products can share an average of 3.0 while one gets only 3s and the other gets half 1s and half 5s. The average hides a big disagreement. The distribution shows it.

Dates, times and text

  • Dates and times are special. You can order them and subtract them to get durations. Write them in an unambiguous format such as 2026-03-04 (year, month, day). The text 03/04/2026 means March 4 in some countries and April 3 in others.
  • Free text is neither a neat category nor a number. Usually you must code it into categories, and you should record the rules you used.

When you get a new dataset, make a quick list: column name, type, unit and a few example values. It takes minutes and prevents many errors later.

Turning one type into another

You can group numeric data into categories, such as ages into "0-17", "18-64" and "65+". This is called binning. It simplifies reading but throws away detail, and the choice of cut points can change the story. Keep the original values when you can, and say how you made the bins. Going the other way, from broad categories back to exact numbers, is not possible.

Practice: classify a real-looking form

A sports club collects the answers below. Try to classify each field before you read the last column.

Field Example value Type
Member number 004512 Nominal label, store as text
Membership level bronze, silver, gold Ordinal
Training sessions last week 3 Discrete count
Best 5 km time 24.6 minutes Continuous, ratio
Joined on 2025-09-14 Date
Wants the newsletter yes Binary categorical
Satisfaction 4 of 5 Ordinal rating

The type then guides the summary. For membership level you could report the count in each level. For session counts, the mean or median both make sense. For the 5 km time, you could report a typical time and the spread. For the join date, you might count new members per month. You would never report an "average member number".

Watch for these mistakes: averaging ID codes, treating ordinal labels as equal steps without saying so, saying "twice as hot" about Celsius values, and making bins with overlaps such as "10-20" and "20-30" (where does 20 go?).

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Which variable is ordinal?

    The sizes have an order, but the gaps between them are not guaranteed to be equal.
  2. 2. A column holds player jersey numbers. What is the sensible type?

    The digits are labels. Their sum or mean says nothing.
  3. 3. Why is 20 degrees Celsius not twice as hot as 10 degrees Celsius?

    Celsius is an interval scale, so differences make sense but ratios do not.
  4. 4. Which is continuous data?

    Time is measured and can take any value in a range. Emails are counted.

Summary

  • Categorical data groups things; numeric data measures or counts amounts.
  • Categories are nominal or ordinal; numbers are often discrete or continuous.
  • The measurement level limits which summaries are meaningful.
  • Digit codes are often labels and are safer stored as text.
  • Binning simplifies data but loses detail.

Next: Tables and Data Formats

Tu progreso se guarda en este navegador. No necesitas una cuenta.