Data Engineering · Module 03
Python for data engineering
- Lessons
- 10
- Free
- 0
- Reading
- ~3 h
Your progress
0 / 10 lessons done
Sign in to trackLessons
- The Python data toolkit: libraries that matterAlmost every data team writes Python around its SQL: scripts that call APIs, read files, run checks and move tables between tools. Picking one library per job, and keeping the heavy work out of Python loops, decides whether that script finishes on time and stays easy to review.
- Reading and writing CSV, JSON and Parquet in PythonMost pipelines start and end with files: a partner’s CSV, an API’s JSON, a Parquet copy for another team. The bugs live in the space between the bytes and the types, and they load without an error.
- DataFrames: pandas and PolarsPipeline code, notebooks and ML libraries pass data around as DataFrames. Knowing what a DataFrame does with your rows, and where its rules differ from SQL, keeps a quick Python step from quietly changing a number.
- Pulling data from APIs: pagination and rate limitsPayment providers, ad platforms and CRMs hand out their data only through APIs, a page at a time and at their own pace. A loop that ignores either rule either crashes at night or quietly loads the wrong numbers.
- Reading and writing databases from PythonAlmost every extract job is Python talking to a database: open a connection, ask for rows, hand them to the destination. The defaults that work on a test table run out of memory, lose their connection or crawl once the table holds a night of real data.
- Processing data larger than memorySooner or later a pipeline has to read more data than its server can hold: a year of history for a model, a backfill, a rebuild after a bug. Knowing what actually has to fit in memory decides whether that job runs on the server you have or needs a cluster.
- Errors, retries and logging in pipeline codeEvery nightly job meets a dropped connection or a busy server sooner or later. Whether that costs a few seconds or a morning of reports depends on what the code retries, what it stops on and what it writes down.
- Testing data code with pytestPipeline code gets changed in a hurry, often an hour before a report is due. A suite of tests that runs in seconds is what keeps each quick fix from quietly undoing an older one.
- Packaging pipelines: config, dependencies and DockerA pipeline script runs on a machine you don’t log in to, at a time nobody watches. Whether it gives the same answer after a server rebuild depends on what you pinned and packaged, not on the code alone.
- Design: a script that loads daily sales filesPartners, banks, couriers and marketplaces still send data as daily files. A loader for them looks like ten lines of Python, and most of the real work is deciding when a file is complete, what it replaces, and what happens when it is wrong.
Practise with
No tools or paper guides for this module yet.
Terms this module teaches 35
Open glossaryApache Arrow
A standard layout for columnar data in memory, the same in every programming language, so programs can share tables without converting each value.
Atomic write
Writing a file under a temporary name and renaming it when complete, so readers see the old file or the whole new one, never part of it.
Base image
The container image a new image starts from, named in the Dockerfile’s FROM line; it decides the operating system files and, for Python images, the Python version.
Bind mount
A folder on the host machine made visible inside a container, so files written there outlive the container.
Bulk load
Writing many rows into a table as one stream or batch, such as PostgreSQL’s COPY or DuckDB’s appender, instead of one INSERT per row.
Control file
A small file a sender uploads after a data file, stating that the data file is complete and how to check it, such as its row count and checksum.
Database driver
A library that connects a program to a database: it opens the connection, sends queries and turns the replies into the language’s own values.
DataFrame
A table held inside a program, with named columns of one type each, and methods to filter, join and group them.
Eager evaluation
Running each step of a computation as soon as it is written, keeping its full result before the next step starts.
Exit code
The number a program returns to whatever started it when it ends: 0 means success, any other value means failure.
Hash aggregation
Running a GROUP BY with a hash table that holds one entry per group and updates that entry for every incoming row.
Hash checking
Installing a package only if the downloaded file’s fingerprint matches the one recorded in advance, so a changed or swapped file is refused.
hot_standby_feedback
A PostgreSQL replica setting that tells the primary which old row versions the replica’s queries still need, so vacuum keeps them. It prevents cleanup conflicts but can bloat tables on the primary. Off by default.
Integration test
A test that runs code against the real system it talks to, such as a database, instead of a stand-in.
Lazy evaluation
Recording the steps of a computation as a plan and running them only when the result is asked for, so the engine can optimise the whole plan first.
Load ledger
A table recording every file or batch a pipeline has seen, with its checksum and status, written in the same transaction as the data it loads.
Lock file
A file listing every package a project installs, direct and transitive, each at one exact version, usually with a hash of each file.
Log level
A label on each log line saying how serious it is, such as DEBUG, INFO, WARNING, ERROR or CRITICAL, so readers and tools can filter by it.
Out-of-memory killer
The part of the Linux kernel that ends a process when the machine runs out of memory, to free memory for the rest.
pandas
The oldest and most widely used Python DataFrame library, built on NumPy; since version 3.0 it stores text with PyArrow when PyArrow is installed.
Parametrized test
One test function that the test runner runs once per set of inputs, reporting each set as a separate test.
Permanent error
A failure caused by the request, the code or the data, so sending the same call again fails the same way. A job should stop on it rather than retry.
Polars
A DataFrame library written in Rust that keeps its columns in the Apache Arrow layout and runs its work in compiled code.
PyArrow
The Python package for Apache Arrow: it holds Arrow tables and reads and writes Parquet files.
pytest fixture
A function marked with @pytest.fixture that builds something a test needs; a test asks for it by naming it as an argument, and code after its yield runs as teardown.
Request pacing
A client spacing its own requests so it stays under an API’s rate limit, instead of sending as fast as it can and waiting for refusals.
Server-side cursor
A cursor whose result stays in the database server, which sends rows to the client in batches as the client asks for them.
Spilling (to disk)
A query engine writing part of an operator’s state to temporary files when it reaches its memory limit, and reading it back later to finish.
Staging table
A scratch table a load fills first, so the real table changes only once all the data has arrived, usually in one transaction.
Standby query conflict
A clash on a PostgreSQL replica between a running query and a change the replica must replay, such as vacuum removing row versions the query can still see. After a set delay, the replica cancels the query.
Streaming execution
Running a query as a pipeline that passes small batches of rows from operator to operator, so only what an operator must remember stays in memory.
Traceback
The list of function calls Python prints when an exception is not handled, ending with the exception itself, showing where the error happened.
Transitive dependency
A package your code doesn’t import itself but gets installed because a package you do import needs it.
Type inference
A reader choosing each column’s type by looking at the values in a file, instead of being told.
Vectorized execution
Running an operation over a block of values in one compiled loop, instead of one interpreter step per value.