Machine learning algorithms are fundamentally mathematical calculators. They perform linear transformations, matrix multiplications, and gradient calculations. However, real-world raw data is rarely purely mathematical—it comes in forms like product ratings, zip codes, salary figures, and user preferences.
Understanding data types is a prerequisite for effective data cleaning, exploratory data analysis (EDA), feature engineering, and selecting the correct machine learning algorithms.
Here is a comprehensive guide to understanding, identifying, and preprocessing data types in data science.
The Master Data Hierarchy
At the highest level, data is classified into two main buckets: Quantitative (Numerical) and Qualitative (Categorical).
1. Quantitative (Numerical) Data
Quantitative data represents measurable quantities expressed as numbers. Standard mathematical operations like addition, subtraction, and averaging are meaningful on numerical data.
A. Discrete Data
Discrete data consists of distinct, countable integer values. It cannot be divided into smaller sub-parts or decimal fractions.
-
Characteristics: Countable, finite or countably infinite, whole numbers only.
-
Examples:
-
Number of customer support tickets submitted ($0, 1, 2, 3$).
-
Total items in an e-commerce cart.
-
Number of cars parked in a lot.
-
Python Representation: int64
B. Continuous Data
Continuous data represents measurements that can take on any real value within a given range. It can be broken down into smaller fractions or decimals depending on measurement precision.
2. Qualitative (Categorical) Data
Qualitative data represents labels, characteristics, or descriptions that divide data into groups. Direct mathematical calculations (like calculating a mathematical average) are not meaningful on raw categorical data.
A. Nominal Data
Nominal data consists of discrete categories with no inherent rank, order, or quantitative value. One category is not greater or smaller than another.
B. Ordinal Data
Ordinal data represents categories that have a clear, natural order or ranking, but the mathematical distance between the categories is non-uniform or unquantified.
Summary Comparison Matrix
| Data Type |
Subtype |
Math Operations Allowed? |
Example |
Machine Learning Encoding Needed? |
| Numerical |
Discrete |
Addition, Multiplication, Averages |
Number of employees |
No (Keep as integers) |
| Numerical |
Continuous |
All arithmetic, scaling, log transforms |
Temperature, Salary |
No (Apply feature scaling) |
| Categorical |
Nominal |
Equality checks ($=$, $\neq$) |
Car brand (Toyota, Ford) |
Yes (One-Hot Encoding) |
| Categorical |
Ordinal |
Comparison operators ($>$, $<$, $=$) |
Service rating (Low, High) |
Yes (Ordinal / Label Encoding) |
How to Prepare Data Types for Machine Learning

Because machine learning models require numerical inputs, categorical features must be transformed into numerical representations through encoding techniques.
1. Handling Ordinal Data: Ordinal Encoding
Since ordinal categories have a meaningful order, map them directly to an ordered sequence of integers.
2. Handling Nominal Data: One-Hot Encoding
Since nominal categories have no order, mapping them to $1, 2, 3$ would accidentally imply a false mathematical sequence (e.g., $3 > 1$). Instead, create binary indicator columns (dummy variables) for each category.
Key Takeaway
Always audit your dataset’s data types early during Exploratory Data Analysis (EDA). Treating ordinal features as nominal destroys valuable sequence information, while treating nominal data as numerical introduces false mathematical relationships into your machine learning models.