Module 2: Data, Types, and Sources
Module 2: Data, Types, and Sources
Introduction to Data Science โ Week 2
Understanding data types, structures, sources, sampling, and bias
Module Overview
Before you can analyze data, you need to understand what kind of data you're working with
and where it came from. This module covers the major data types and structures, the
difference between primary and secondary data, the most common data sources, and the
principles of good sampling. By the end of the week, students will be able to classify
any dataset by type, structure, and level of measurement โ and recognize common sources
of bias.
Learning Objectives
By the end of this module, students will be able to:
- Classify data by type (quantitative vs. qualitative) and structure (structured vs. unstructured).
- Identify the four levels of measurement and what operations each allows.
- Distinguish primary from secondary data and give examples of each.
- Describe common data sources: surveys, databases, APIs, web scraping, and sensors.
- Explain the difference between a sample and a population.
- Recognize common sampling biases and how to avoid them.
Lesson 1: Types of Data
Data comes in many forms. Before choosing a method of analysis, you must know what kind of
data you have.
Quantitative vs. Qualitative
| Aspect |
Quantitative |
Qualitative |
| Nature |
Numbers and measurements |
Descriptions, categories, text |
| Examples |
Age, income, temperature, sales |
Color, customer feedback, product category |
| Analysis |
Statistics, averages, trends |
Themes, patterns, categorization |
Discrete vs. Continuous (a subset of quantitative)
- Discrete: Countable, whole numbers (e.g., number of siblings, number of cars).
- Continuous: Measurable, can take any value in a range (e.g., height, temperature, time).
๐ Think of it like this: Discrete data is like counting slices of pizza โ
you can have 2 or 3, but not 2.5. Continuous data is like measuring how much pizza is left โ
you can have any amount, even 2.37 slices!
๐ก Key Idea: The type of data determines what statistics and charts you can
use. You can calculate an average of heights, but not of eye colors.
Lesson 2: Data Structures
Structured vs. Semi-Structured vs. Unstructured
| Structure |
Description |
Examples |
| Structured |
Organized in rows and columns with defined types |
Spreadsheets, relational databases, CSV files |
| Semi-structured |
Partially organized with tags or keys |
JSON, XML, emails, log files |
| Unstructured |
No fixed format; requires processing to organize |
Images, video, audio, free text, social media posts |
โ ๏ธ Fun Fact: Most of the world's data is unstructured โ
images, videos, and text make up far more data than neat tables. This is why modern data
science increasingly involves natural language processing and computer vision.
๐ก Key Idea: Structured data is easy to analyze but limited in scope.
Unstructured data is rich but requires more work to extract insight.
Lesson 3: Levels of Measurement
The level of measurement determines what mathematical operations are valid:
| Level |
Description |
Example |
Valid Operations |
| Nominal |
Categories with no order |
Eye color, city, gender |
Count, mode |
| Ordinal |
Categories with a meaningful order |
Satisfaction ratings (1โ5), education level |
Count, mode, median, rank |
| Interval |
Equal intervals, no true zero |
Temperature in ยฐC, IQ scores |
Add, subtract, mean, standard deviation |
| Ratio |
Equal intervals with a true zero |
Height, income, weight, age |
All operations, including ratios |
๐ฎ Think of it like game levels: Each level unlocks new abilities. At the
nominal level, you can only count. At the ordinal level, you can also rank. At the interval
level, you can add and subtract. At the ratio level, you can do everything, including say
"twice as much."
โ ๏ธ Classic Trap: Temperature in ยฐC is interval, not ratio. 20ยฐC is not
"twice as hot" as 10ยฐC โ that's why we can't say the ratio is 2. But 20 kg is twice
as heavy as 10 kg, because weight has a true zero.
Lesson 4: Primary vs. Secondary Data
| Aspect |
Primary Data |
Secondary Data |
| Definition |
Data you collect yourself |
Data someone else collected |
| Examples |
Surveys, interviews, experiments, sensors you installed |
Government statistics, open datasets, company reports |
| Advantages |
You control the questions and quality |
Faster, cheaper, often larger |
| Disadvantages |
Time-consuming and often expensive |
You have to trust the source; may not fit your question |
๐ณ Think of it like cooking: Primary data is like growing your own vegetables โ
you know exactly where they came from. Secondary data is like buying vegetables at the store โ
faster, but you have to trust the label.
๐ก Key Idea: Neither is "better." The right choice depends on your question,
your budget, your timeline, and how much control you need over data quality.
Lesson 5: Common Data Sources
Surveys and Questionnaires ๐
- Great for collecting opinions, behaviors, and demographics.
- Watch out for leading questions, low response rates, and self-report bias.
Databases and Data Warehouses ๐๏ธ
- Store structured data for organizations (e.g., customer records, transactions).
- Accessed via SQL; often the largest and most reliable source of business data.
APIs (Application Programming Interfaces) ๐
- Programmatic access to data from services (e.g., Twitter, weather, financial data).
- Requires reading documentation and handling rate limits.
Web Scraping ๐ท๏ธ
- Extracting data from websites automatically.
- Must respect terms of service, robots.txt, and copyright.
Sensors and IoT Devices ๐ก
- Generate continuous streams of data (e.g., smartwatches, weather stations).
- Often high-volume and time-series in nature.
โ ๏ธ Before Using Any Source, Ask:
- Who collected this data, and why?
- When was it collected? Is it still relevant?
- How was it collected? (Method matters!)
- Is it representative, or biased in some way?
Lesson 6: Sampling and Bias
A population is the entire group you want to study. A
sample is a smaller subset you actually collect data from.
Good sampling is the foundation of trustworthy data science.
Common Sampling Methods
| Method |
How It Works |
Strengths and Weaknesses |
| Simple Random |
Every member has an equal chance of being selected |
Fair and unbiased, but may miss small subgroups |
| Stratified |
Divide into groups, then sample from each |
Ensures all groups are represented |
| Systematic |
Pick every nth member |
Easy, but can miss patterns |
| Convenience |
Sample whoever is easiest to reach |
Fast, but often biased |
Common Biases
- Selection bias: The sample isn't representative (e.g., only surveying people who own smartphones).
- Survivorship bias: Only looking at "survivors" and ignoring those who dropped out (e.g., only studying successful companies).
- Response bias: People answer inaccurately due to social pressure or poor question design.
- Non-response bias: People who don't respond differ from those who do.
โ ๏ธ Famous Fail! In 1936, the Literary Digest surveyed 2.4 million
people about the US presidential election. Their prediction was wrong โ because they sampled
from phone books and car registrations, which overrepresented wealthier voters. A smaller,
truly random sample (like Gallup's) was more accurate. Bigger isn't always better โ
representative is what matters.
๐ก Key Idea: A small, random sample is often better than a huge, biased one.
Always ask: How was this data collected, and who might be missing?
Hands-On Lab: Classify and Evaluate a Dataset
Goal: Practice classifying data by type, structure, and level of measurement โ and evaluate its source.
Instructions
- Download a small open dataset (e.g., from Kaggle, data.gov, or a CSV from a public API).
- Open it in a spreadsheet tool.
- Identify each column and classify it:
- Is it quantitative or qualitative? Discrete or continuous?
- Is it nominal, ordinal, interval, or ratio?
- Is the overall dataset structured, semi-structured, or unstructured?
- Evaluate the source:
- Is this primary or secondary data?
- Who collected it, and when?
- How might it be biased? What's missing?
- Write 3โ5 sentences describing the dataset and one question you could answer with it.
Submission
A short write-up (one page) with:
- A table classifying each column
- Your source evaluation and any biases you noticed
- One question you could answer with the dataset
- A link to the dataset
Assessment for Module 2
- Quiz (10 questions): Covers data types, structures, levels of measurement, sources, and sampling.
- Lab write-up: Graded on completeness and accuracy of classification and source evaluation.
- Participation: Contribution to the group activity and discussion prompts.
Key Terms
- Quantitative data โ numerical data.
- Qualitative data โ categorical or descriptive data.
- Discrete data โ countable values.
- Continuous data โ values that can take any point in a range.
- Structured data โ data in a fixed format like rows and columns.
- Unstructured data โ data without a fixed format (text, images, audio).
- Nominal, ordinal, interval, ratio โ the four levels of measurement.
- Primary data โ data you collect yourself.
- Secondary data โ data someone else collected.
- Population โ the whole group being studied.
- Sample โ a smaller subset of the population.
- Bias โ systematic unfairness in data or sampling.
Discussion Prompts
- Can you think of a time when a survey or poll turned out to be wrong? What kind of bias might have been at play?
- Why do you think most of the world's data is unstructured? What challenges does that create?
- What's the difference between discrete and continuous data? Give an example of each from your own life.
- Which sampling method would you use if you wanted to understand the opinions of students in your school? Why?
- Why is a small, random sample sometimes more accurate than a huge, biased one?
Further Reading
- Joel Grus, Data Science from Scratch โ Chapter 2 ("A Crash Course in Python") and related sections
- Kaggle Learn: "Intro to Data Analysis" (free micro-course)
- Any introductory statistics textbook โ chapter on data types and sampling
- Nate Silver, The Signal and the Noise โ chapters on polls and predictions
๐ก Instructor Note: This module builds critical data literacy. Emphasize that
where data comes from matters just as much as what it says. Encourage students
to question sources โ including your own examples โ and to bring real-world examples of biased
samples to class.