2  Data and Its Types

Data is the raw material of every analysis you will ever run. Before you can compute a mean, draw a chart, or train a model, you need to know exactly what kind of data you are holding, because the type of data determines which summaries make sense, which charts are appropriate, and which statistical tests are even valid.

This chapter builds that vocabulary. You will learn what data is, where it comes from, how it is classified by nature, and how the four levels of measurement, nominal, ordinal, interval, and ratio, decide what you are allowed to do with a variable mathematically.

2.1 What Is Data?

Data refers to facts, figures, and observations collected about people, objects, or events, recorded in a form that can be communicated, stored, and analyzed. A single data point, such as one customer’s age or one product’s price, is called an observation. A collection of observations across one or more variables forms a dataset.

  • Data: Raw, unprocessed facts, such as the number 42 or the word “Delhi” recorded against a customer record.
  • Information: Data that has been organized and given context, such as “average customer age is 42 years.”
  • Variable: A characteristic that can take different values across observations, such as age, income, or product category.

Data on its own does not answer questions. A single number like 42 tells you nothing until it is organized, compared, and interpreted, which is precisely what the rest of this book teaches you to do, starting with the classification and tabulation methods in the next chapter.

2.2 Sources of Data

Every dataset originates from one of two broad sources, and knowing the source affects how much you trust the data and how you should clean and interpret it.

  • Primary Data: Data collected firsthand by the analyst or organization for a specific purpose, through surveys, experiments, interviews, or direct observation. It is original and tailored to the research question, but collecting it costs time and money.
  • Secondary Data: Data that already exists, having been collected by someone else for a different purpose, such as government statistics, company records, or published research. It is faster and cheaper to obtain, but may not perfectly fit the current question and its quality depends on the original collector.

Example

A retail chain wants to understand why sales dropped in a region. Sending a fresh customer satisfaction survey to shoppers in that region produces primary data. Pulling last year’s point-of-sale transaction records from the company’s own database, originally logged for accounting purposes, produces secondary data that can be repurposed for this new question.

Secondary data is convenient, but never assume it is clean or complete simply because it comes from an official-looking source. Always check how, when, and why the data was originally collected before relying on it for a new analysis.

2.3 Types of Data by Nature

Every variable in a dataset falls into one of two broad families based on the nature of the values it can take.

  • Qualitative (Categorical) Data: Describes a quality or category rather than a quantity. Values are labels, such as gender, city, or product type, and cannot be meaningfully averaged.
  • Quantitative (Numerical) Data: Describes a measurable quantity expressed as a number, such as height, income, or number of orders, and supports arithmetic operations like addition and averaging.

Quantitative data further splits into two subtypes:

  • Discrete Data: Takes only specific, countable values, usually whole numbers, with no meaningful values in between. The number of children in a household or the number of defective items in a batch are discrete, since you cannot have 2.5 children or 3.7 defects.
  • Continuous Data: Can take any value within a range, including fractions and decimals, limited only by the precision of measurement. Height, weight, temperature, and time are continuous, since a person’s height could be 165.3 cm or 165.34 cm depending on how precisely it is measured.

Example

Consider a student records dataset with the columns: Name (Ravi, Priya, Aman), Gender (Male, Female), Marks Scored (78, 85, 91), and Number of Siblings (0, 1, 2). Name and Gender are qualitative. Marks Scored is quantitative and continuous, since a mark could in principle be 78.5. Number of Siblings is quantitative and discrete, since siblings are always counted in whole numbers.

Application

Recognizing whether a column is qualitative or quantitative, and discrete or continuous, is the very first step of any real analysis. It decides whether you compute a mean or a mode, draw a histogram or a bar chart, and it is exactly the judgment call every str() in R or .dtypes in Python is asking you to make.

2.4 Levels of Measurement

Beyond qualitative and quantitative, every variable also has a level of measurement, sometimes called its measurement scale, which determines exactly what mathematical and statistical operations are valid on it. There are four levels, each one adding a capability the previous level lacked.

  • Nominal: Categories with no inherent order. Values only identify group membership. Example: blood group (A, B, AB, O), marital status, product category.
  • Ordinal: Categories with a meaningful order, but the gap between categories is not necessarily equal or measurable. Example: customer satisfaction rating (Poor, Average, Good, Excellent), education level, military rank.
  • Interval: Numeric values with equal, meaningful gaps between them, but no true zero point, so ratios are not meaningful. Example: temperature in Celsius, where 0°C does not mean “no temperature,” and calendar year.
  • Ratio: Numeric values with equal gaps and a true, meaningful zero point, so both differences and ratios are meaningful. Example: height, weight, income, and age, where 0 genuinely means “none” and 40 kg is twice as heavy as 20 kg.
Scale Identifies Categories Has Order Equal Intervals True Zero Example
Nominal Yes No No No Gender, City, Product Type
Ordinal Yes Yes No No Satisfaction Rating, Grade (A, B, C)
Interval Yes Yes Yes No Temperature (°C), Calendar Year
Ratio Yes Yes Yes Yes Height, Weight, Income, Age

The most common measurement-level mistake is treating ordinal data as if it were interval data, for example averaging a 1-to-5 satisfaction rating and reporting “the average satisfaction was 3.4” as though the distance between “Poor” and “Average” is identical to the distance between “Good” and “Excellent.” Strictly, ordinal data supports the median and mode, not the arithmetic mean, though in practice many analysts do average Likert-scale data as a convenient approximation. Know that you are making that trade-off when you do it.

A quick test to identify the level of measurement: ask whether the values can be ordered (rules out nominal), whether the gaps between values are equal and measurable (rules out ordinal), and whether zero genuinely means “none of this quantity” (separates interval from ratio). Working through these three questions in order will correctly classify almost any variable you encounter.

2.5 Why Data Types Matter for Analysis

The level of measurement is not academic trivia, it is a gatekeeper that decides which statistical tools you are allowed to use later in this book.

  • Mode works for every level, nominal through ratio, since it only asks “what occurs most often.”
  • Median requires at least ordinal data, since it depends on being able to rank values from smallest to largest.
  • Mean, variance, and standard deviation require interval or ratio data, since they depend on the gaps between values being numerically meaningful.
  • Ratios and percentage change require ratio data specifically, since they depend on a true zero.

Every measure of central tendency and dispersion covered later in this book inherits these restrictions directly from the data type discussion in this chapter.

Looking Ahead

With a working vocabulary for what data is, where it comes from, and how it is classified, the next chapter turns to organizing raw, unsorted observations into arrays, and classifying and tabulating them so that patterns become visible.


Summary

Concept Description
Data Basics
Data Raw, unprocessed facts and figures collected about people, objects, or events
Information Data that has been organized and given context so it becomes meaningful
Variable A characteristic that can take different values across observations, such as age or income
Sources of Data
Primary Data Data collected firsthand by the analyst for a specific purpose, through surveys or experiments
Secondary Data Data collected earlier by someone else for a different purpose, then reused for the current question
Nature of Data
Qualitative Data Data describing a quality or category, such as gender or product type, that cannot be meaningfully averaged
Quantitative Data Data describing a measurable quantity expressed as a number, such as income or number of orders
Discrete Data Quantitative data that takes only specific, countable values with no meaningful values in between
Continuous Data Quantitative data that can take any value within a range, limited only by measurement precision
Levels of Measurement
Nominal Scale A measurement scale with categories but no order, such as blood group or marital status
Ordinal Scale A measurement scale with a meaningful order but unequal or unmeasurable gaps, such as a satisfaction rating
Interval Scale A measurement scale with equal, meaningful gaps but no true zero point, such as temperature in Celsius
Ratio Scale A measurement scale with equal gaps and a true zero point, such as height, weight, or income
What Each Level Allows
Mode Applicability The mode can be computed for data at any level of measurement, nominal through ratio
Median Applicability The median requires data that can be ranked, so at minimum an ordinal scale
Mean Applicability The mean requires numerically meaningful gaps between values, so at minimum an interval scale
Ratio Applicability Ratios and percentage change require a true zero point, so they are valid only for ratio-scale data