DSM
40 XP
20 minsBeginner40 XP

Types of Data

Ask a data scientist the first question they ask about a new dataset and it's almost always the same: 'What kind of data is this?' The answer decides everything that follows — how you store it, how you clean it, and which charts and calculations even make sense. Get the type wrong and you'll try to average a phone number. By the end of this lesson you'll classify any value on sight.

What you'll learn

  • Explain the difference between structured and unstructured data
  • Classify a value as numerical or categorical
  • Split numerical data into discrete and continuous
  • Split categorical data into nominal and ordinal
  • Pick a valid summary (mean, count, mode) based on the data type

What

Data comes in kinds. The two most useful splits are: structured vs. unstructured (does it fit neatly in a table?) and, for structured columns, numerical vs. categorical (is it a measurable number or a label?).

Why

The type of a value determines what you're allowed to do with it. You can average a numerical column but not a categorical one; you can count categories but you can't take their mean. Knowing the type up front stops you from making meaningless calculations.

Where it's used

Every spreadsheet, database, survey, and machine learning model. Choosing an average vs. a mode, a bar chart vs. a histogram, or a text model vs. a table model all start from the data type.

Where this runs in production

SpotifyOne song, many data types

A track row mixes types: duration in seconds is continuous numerical, play count is discrete numerical, genre is nominal categorical, and the lyrics are unstructured text. Each is handled differently.

AmazonStructured orders, unstructured reviews

Your order history is structured — price, quantity, date, all in tidy columns. Your written product reviews are unstructured text that needs language processing before it becomes useful.

UberRatings are ordinal, not just numbers

A 1-to-5 driver rating looks numerical but is ordinal categorical — the order matters (5 beats 4) but the gaps aren't guaranteed equal, so Uber treats it carefully when averaging.

Theory

The core ideas, in plain language.

Start with the biggest split: structured vs. unstructured. Structured data fits neatly into rows and columns — a spreadsheet, a database table. Unstructured data does not — free text, images, audio, video. Most beginner data work happens on structured data, so we'll focus there.
Analogy: A filing cabinet vs. a shoebox of photos

Structured data is a filing cabinet: every document has a labelled folder and a fixed place. You can instantly find 'March invoices.' Unstructured data is a shoebox of photos: rich and valuable, but you can't sort it by a column because there are no columns. To search it, you first have to add structure — tags, dates, faces.

Key Concept
Numerical vs. categorical

Within structured data, every column is either numerical (a measured quantity you can do arithmetic on — price, age, temperature) or categorical (a label that names a group — colour, city, yes/no). The single best test: does taking an average make sense? If yes, it's numerical. Averaging 'red' and 'blue' is nonsense — so colour is categorical.

Numerical data splits again. Discrete data counts things and only takes whole values — number of children, cars sold, login attempts. Continuous data measures things and can take any value in a range — height, weight, time, temperature.
children = 3          # discrete: you can't have 2.5 children
height_cm = 172.4     # continuous: any value in a range
city = 'Lagos'        # categorical (nominal): a label, no order
rating = 4            # categorical (ordinal): a label WITH order

Notice that `rating = 4` is stored as a number but behaves like a category — the order matters but the gaps may not be equal. How a value is stored doesn't always match what kind of data it truly is. Always ask what the value means, not just how it looks.

Categorical data also splits in two. Nominal categories have no natural order — country, colour, product name. Ordinal categories have a meaningful order but unclear gaps — 'small / medium / large', star ratings, education level. The order lets you rank them, but you can't safely say medium minus small equals a fixed amount.
Watch out
A number stored in a column isn't always numerical data

Postal codes, phone numbers, and customer IDs are stored as digits but are really categorical labels — averaging them is meaningless. Before treating a column as numerical, ask: 'Would arithmetic on these values mean anything?' If not, it's categorical, whatever it looks like.

Visual Learning

See the concept, then explore it.

The Data Type Family Tree

Click any node to see its definition, an example, and the summary you're allowed to compute for it.

Worked Examples

Watch it built up, one line at a time.

Very EasyNumerical or categorical?

You open a customer table with a column called age holding values like 27, 34, 41.

Step 1 of 1

Apply the average test: the mean age of these customers (34) is a meaningful, useful number. So age is numerical data.

Code
01age = [27, 34, 41] # does averaging make sense?
Output
age → numerical (the average is meaningful).
Practice Coding

Your turn — write the code.

Your task

You're handed one row from an e-commerce orders table. Label each column with the correct data type by filling in the blanks. Use exactly one of these strings for each: "numerical" or "categorical". Remember the average test — if taking a mean is meaningless, it's categorical, even if it looks like a number.

Expected output
categorical numerical numerical categorical

Write your solution in the editor on the right, then hit Run.

Exercises

Prove it. Reach 80% to complete the lesson.

Mastery Gate0% / 80% required
Easy0/2 solved

Which of these is unstructured data?

What is the quickest test for whether a column is numerical rather than categorical?

Medium0/3 solved

A column counts the number of items in each customer's cart: 1, 3, 0, 2. What type is it?

ScenarioA survey stores satisfaction as 'Poor', 'Fair', 'Good', 'Excellent'. A teammate wants to convert them to 1, 2, 3, 4 and then take the average.

What is the right way to think about this?

You have a list of city names for delivery stops: cities = ['Lagos', 'Nairobi', 'Lagos', 'Accra', 'Lagos']. Because city is categorical, the right summary is the mode (most frequent value), not the mean. Print the most common city. Use only what you know: you may use the list's .count() method.

Correct summary type:Uses the mode (most frequent), not an average.
Output:Prints Lagos, which appears three times.
Hard0/1 solved
ScenarioA dataset has a phone_number column stored as large integers, and a marketing analyst suggests using its average as a feature in a model.

How should you respond?

Complete 80% more exercises to unlock.
Interview Prep

How this shows up in real interviews.

What is the difference between structured and unstructured data? Give an example of each.

Show model answer

Structured data fits neatly into rows and columns, like a spreadsheet or a database table of orders — it's easy to filter, sort, and summarise. Unstructured data has no such fixed shape: free text, images, audio, and video. For example, a customer's order history is structured, while the text of their written review is unstructured and needs language processing before it becomes analysable. Most organisations have far more unstructured data, but structured data is where most analysis starts.

What's the difference between nominal and ordinal categorical data, and why does it matter in practice?

Show model answer

Both are categories, but ordinal data has a meaningful order while nominal data doesn't. Colour and country are nominal — no colour is 'greater' than another. Size (S, M, L) or a satisfaction rating (Poor to Excellent) is ordinal — the order is real. It matters because the type dictates valid operations: for both you can count and take a mode, but only for ordinal can you rank or sort meaningfully. The subtle trap is that the gaps between ordinal levels aren't guaranteed equal, so converting them to 1, 2, 3 and averaging can mislead. In modelling, this also drives your encoding choice — one-hot encoding for nominal, ordinal encoding for ordinal.

A column is stored as integers. What questions do you ask before treating it as numerical data in a model, and why?

Show model answer

The storage type tells you almost nothing — I'd ask what the values actually mean. My first question is whether arithmetic on them is meaningful: does the average or sum point to something real? If it's a zip code, phone number, or product ID, the answer is no — it's a categorical identifier wearing a numeric costume, and feeding its average into a model adds noise or spurious structure. My second question is whether it's really ordinal, like a 1-to-5 rating, where order matters but equal gaps don't, which changes how I encode it. I'd also check the cardinality: an integer column with only a handful of distinct values is often a category in disguise. Getting this wrong is one of the most common quiet bugs in a feature pipeline, because the code runs fine while the results are meaningless.

Common Mistakes to Avoid

1) Treating any digits as numerical — zip codes, phone numbers, and IDs are categorical labels. 2) Averaging ordinal ratings as if the gaps between levels were equal. 3) Confusing discrete (counts, whole numbers) with continuous (measures, any value in a range). 4) Forgetting that how a value is STORED (as text or a number) doesn't always match what KIND of data it truly is — always ask what the value means.

Ask the AI Tutor

Try these prompts in the AI Tutor panel: • 'Give me 10 random values and quiz me on their data type.' • 'ELI5: why can't I average a categorical column?' • 'Explain nominal vs. ordinal with a fresh example.' • 'Show me a column that looks numerical but is actually categorical.' • 'Summarise the data type family tree in five bullet points.'

Glossary

Structured data — data organised in rows and columns (tables). Unstructured data — data with no fixed table shape (text, images, audio). Numerical data — measured quantities you can do arithmetic on. Categorical data — labels naming a group. Discrete — numerical values that are whole counts. Continuous — numerical values that can take any value in a range. Nominal — categories with no order. Ordinal — categories with a meaningful order but unclear gaps. Mode — the most frequent value; the valid 'centre' for categorical data.

Recommended Resources

• Reference: 'Levels of measurement' (nominal, ordinal, interval, ratio) on Wikipedia — the classic framework this lesson simplifies. • Article: 'Structured vs. Unstructured Data' explainers from IBM and Google Cloud. • Practice: open any spreadsheet you have and label every column's type before reading its contents. • Next in DSM: with data types in hand, you're ready to see the full journey a project takes — the data science workflow.

Recap

✓ Structured data fits in rows and columns; unstructured data (text, images, audio) does not. ✓ Structured columns are either numerical (arithmetic makes sense) or categorical (labels). ✓ Numerical splits into discrete (whole counts) and continuous (any value in a range). ✓ Categorical splits into nominal (no order) and ordinal (ordered, but unequal gaps). ✓ The average test settles most cases — and a value's storage format doesn't always match its true type. Next up: The Data Science Workflow. Now that you can read the raw material, you'll follow it through an entire project — from the first question to the final decision — and see why real data work loops instead of running in a straight line.

scratchpad — preview this lesson's challenge anytime
type_the_columns.pyPython
Ready
Output

Run your code to see the output here.