Formats & Schemas

P12.data-pipelines.02 · Audience: guest, it-ml, language-pro · Prerequisites: From Notebook to Pipeline

Before a pipeline can transform data, it has to read it from somewhere and write it somewhere — and the file format it uses is a real engineering decision, not an afterthought. A million-row export saved the convenient way can be ten times larger and ten times slower to read than the same data saved the deliberate way. Worse, a format can quietly let a column lie about what it holds: a price stored as text, a missing value that turned into the literal word NA. This module is about how data is stored — and how a schema turns a loose pile of bytes into a contract you can actually trust.

Step 1 / 5Rows on disk, or columns on disk

All three formats hold the same table — the difference is how the bytes are laid out on disk, and that one choice drives everything else. A row-oriented format writes one whole record after another: all of row 1's fields, then all of row 2's. A columnar format writes one whole column after another: every city, then every price, then every quantity.

Why care? Because most analytics reads a few columns across all rows — "sum the revenue", "average the quantity" — not whole records. When a column sits together on disk, the reader grabs exactly that column and skips the rest; and because a column holds all-similar values, it compresses far better than a row of mixed types. Row formats are the opposite bet: cheap to append one record at a time and easy for a human to read, but the reader must walk every field of every row even to sum a single column.

ⓘ Concept: Row-oriented vs columnar is the root trade-off
row-oriented: whole records together → easy to read & append, slow & large to scan · columnar: whole columns together → fast & small to scan, binary & write-once

Why it matters — Almost every difference between these formats follows from this one layout choice. Columnar storage (Parquet) wins analytics: read only the columns you need, compress each column hard, scan huge tables fast — at the cost of being a binary format no one can open in a text editor and slower to write a single new row. Row storage (CSV, JSON) wins for readability, easy appends and interchange, at the cost of size and scan speed. Choosing a format is really choosing which of these you are optimising for.

Ask the mentor about this module

Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.

Ctrl/Cmd + Enter to send

Try it yourself

A scratch console for this page's ideas — ungraded, nothing you run here is recorded.

Scratch console

A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.

Output appears here.