Python for data engineers
20 in-depth lessons. The Python that data engineering interviews test: what each data structure costs, comprehensions and collections, decorators and generators, classes and context managers, wrangling without pandas, and the algorithms behind heaps, windows, binary search and DAG scheduling.
Bronze
Module 1: Python basics for data engineers
Use dict, set, list and string methods, the built-ins, files, JSON, CSV and dates without surprises.
- Dict, set and list methods · Bronze · 7 min read. get, setdefault, views, set operations, append versus extend, remove and slicing, with the traps in each.
- Strings and built-in functions · Bronze · 6 min read. split, join, strip, f-strings, zip, enumerate, any, all, min, max and sorted, and their surprises.
- Files, JSON, CSV and dates · Bronze · 8 min read. Read files line by line, JSON and CSV, ISO dates, strptime codes, time zones and zoneinfo.
Module 2: Built-in data structures
Choose the right container, and count, group and window data with collections.
- Lists, dicts and sets: what each operation costs · Bronze · 7 min read. Pick the container from the question, and why a set turns an hour-long loop into a second.
- Comprehensions · Bronze · 5 min read. List, dict and set comprehensions, filtering versus choosing, nesting, and generator expressions.
- Counter, defaultdict and deque · Bronze · 6 min read. Count, group and keep the last N with the collections module, and the traps in each.
Module 3: Everyday idioms
Sort by anything, avoid aliasing bugs, and write functions that keep state.
- Sorting with key functions · Bronze · 5 min read. Tuple keys, mixed directions, stability and data with None in it.
- Mutability, copies and default arguments · Bronze · 4 min read. What assignment really does, shallow versus deep copies, and the mutable default trap.
- Functions, *args, **kwargs and closures · Bronze · 8 min read. Every kind of parameter, closures that remember state, nonlocal and late binding.
Silver
Module 4: Functions and laziness
Decorate functions, and stream data through generator pipelines.
- Decorators · Silver · 8 min read. What @ does, wrappers for any function, functools.wraps, and decorators with arguments.
- Generators and lazy evaluation · Silver · 6 min read. yield, constant-memory pipelines, endless inputs and the one-pass rule.
- Iterators, yield from and itertools · Silver · 8 min read. The iterator protocol, re-iterable classes, recursive generators and the itertools you will use.
Module 5: Classes and robust code
Model records with rules, and clean up whatever happens.
- Classes, properties and dataclasses · Silver · 4 min read. Invariants, validated and read-only attributes, alternate constructors and record types.
- Exceptions and context managers · Silver · 5 min read. try/except/else/finally, custom exceptions, with blocks, contextlib and logging.
Module 6: Wrangling
Parse, flatten, deduplicate, join and aggregate data in plain Python.
- Wrangling data without pandas · Silver · 5 min read. Parse, flatten, deduplicate, join and aggregate in plain Python, with SQL's null rules.
Gold
Module 7: Objects that behave like values
Make your classes comparable, hashable and enforce interfaces.
- Dunder methods and abstract classes · Gold · 7 min read. Equality, ordering and hashing that agree, NotImplemented, and interfaces with abc.
Module 8: Algorithms interviewers ask
Heaps, sliding windows, binary search and topological sort.
- Heaps, top-k and k-way merges · Gold · 7 min read. heapq, top-k in O(n log k), tie-breaking tuples, and merging sorted streams.
- Sliding windows, sweeps and binary search · Gold · 5 min read. O(n) windows, sort-then-sweep for intervals, and bisect for as-of lookups.
- Graphs and topological sort · Gold · 7 min read. Dependency graphs, Kahn's algorithm, cycle detection and how schedulers use them.
Module 9: Performance
Read Big-O from code and fix what makes jobs slow.
- Big-O and performance for data engineers · Gold · 5 min read. Read complexity from code, find hidden quadratics, stream instead of loading, and measure.