Skip to content
Saed Sayad

Data Preparation

How raw measurements become a modeling-ready dataset: data types, dataset anatomy, databases and SQL, and the ETL pipeline that ties them together.

6 min read · Updated August 8, 2026

Data preparation is the work of constructing a dataset from one or more data sources so it can be explored and modeled. It is usually the most time-consuming phase of a data science project, and the most error-prone — the old saying “garbage in, garbage out” applies with full force to data assembled with invalid, out-of-range, or missing values.

Analyzing data that has not been carefully screened produces misleading results, so the success of the whole project depends on the quality of the prepared data. This page covers the vocabulary you need before touching any algorithm: what data is, what a dataset looks like, where data lives, and how it gets moved.

Data

Data is information, typically the result of measurement (numerical) or counting (categorical). A variable is a placeholder for data, and there are two types.

Taxonomy of data: measurement produces ratio and interval (numerical) data; counting produces ordinal and nominal (categorical) data
The four data types, grouped by how the data is produced and which variable type it becomes.

A numerical (or continuous) variable can take any value within a finite or infinite interval — height, weight, temperature, blood glucose. It comes in two subtypes:

  • Interval data can be added and subtracted but not meaningfully multiplied or divided, because there is no true zero. One day is not “twice as hot” as another.
  • Ratio data has a true zero and supports all four arithmetic operations — weight, for example.

A categorical (or discrete) variable takes two or more values called categories:

  • Nominal data has no intrinsic ordering among categories — for example, gender.
  • Ordinal data has an intrinsic ordering — for example, level of energy: low, medium, high.

The distinction matters downstream: ordinal categories can be given meaningful integer codes, while nominal ones usually need one-hot encoding.

Datasets

A dataset is a collection of data, usually in tabular form. Each column represents a variable and each row corresponds to one member of the data. Synonyms abound: columns are also called fields, attributes, or variables; rows are records, objects, cases, instances, examples, or vectors; the cells hold values.

Here is a raw dataset — the Play Golf data used throughout the classification tutorials, exactly as it might arrive before preparation:

IDOutlookTempHumidityWindyPlay Golf
1Rainy8582FalseNo
2Rainy8068TrueNo
3Overcast8386FalseYes
4Sunny7080FalseYes
5Sunny68?FalseYes
6Sunny6558TrueNo
7Overcast6462TrueYes
8Rainy7295?No
9Rainy?70FalseYes
10Sunny7572FalseYes
11Rainy7574TrueYes
12?7278TrueYes
13Overcast8166FalseYes
14Sunny7179TrueNo

Even this tiny table shows what preparation means. Four values are missing (rows 5, 8, 9, 12) and must be imputed or their rows dropped. Temp and Humidity arrive as raw numbers, but the classification tutorials model them as categories — Cool/Mild/Hot and Normal/High — produced by binning. The prepared result is the clean, fully categorical 14-row dataset used by ZeroR, OneR, and the other classification pages.

Databases and SQL

A database collects, stores, and manages information so users can retrieve, add, update, or remove it, presenting it in tables of rows and columns. A table is a relation — a collection of objects of the same type — and retrieving related data from related tables through common keys is the basis of the term relational database. A Database Management System (DBMS) handles how data is stored, maintained, and retrieved; most data science toolboxes connect through ODBC or JDBC interfaces.

SQL (Structured Query Language) manages and manipulates data in relational systems. Its Data Definition Language (DDL) shapes structure — CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, DROP INDEX — while its Data Manipulation Language (DML) works with the data itself: SELECT, INSERT INTO, UPDATE, DELETE.

ETL

ETL — Extraction, Transformation, and Loading — moves data from sources to destinations through transformation functions: extraction pulls from flat files, relational databases, streams, XML, and ODBC/JDBC sources; transformation cleanses, converts, aggregates, merges, and splits; loading writes the result into destination tables, row by row or in bulk.

ETL process: data flows from source systems through extract, transform, and load stages into destination tables
The ETL pipeline: extract from sources, transform into shape, load into the destination.

In practice

In Python, preparation typically starts with pandas or Polars for tabular wrangling and SQL for anything already in a database; scikit-learn’s ColumnTransformer and Pipeline then package the imputation, encoding, and binning steps so they re-fit cleanly on every run. Modern warehouses shift the pattern from ETL to ELT — load first, transform in place with tools like dbt — but the checklist is the same. Whatever the stack, fit every learned transformation (imputation values, bin edges, encoding maps) on training data only, or you leak the future into the past.

Common pitfalls

  • Ignoring missing and invalid values. Even a handful of ? cells can silently bias a model or crash a pipeline.
  • Treating nominal codes as ordinal. Assigning arbitrary integers to unordered categories invents an ordering that distance- and split-based models will happily exploit.
  • Mixing up interval and ratio data. Ratios like “twice as hot” are meaningless on an interval scale.
  • Preparing before splitting. Computing imputations, bin edges, or encodings on the full dataset leaks test information into training.
  • Underestimating the effort. Preparation routinely consumes most of a project’s time; budget for it.

Summary

Data preparation turns raw sources into a clean, modeling-ready dataset. Data is numerical (interval or ratio) or categorical (nominal or ordinal); a dataset arranges variables as columns and cases as rows, with predictors feeding a target. Databases store the data, SQL manipulates it, ETL moves and reshapes it — and every downstream result inherits the quality of this work.