Python / coding round
The DE coding round is usually less algorithmic than a software engineering one, and more about data: parsing messy input, streaming large files, calling flaky APIs, transforming records, and writing code you'd trust in a pipeline.
What gets tested
- Parsing and validation: logs, CSV, JSON with missing or wrong fields. Never crash on one bad record; count and report it.
- Streaming and memory: generators,
itertools, processing a file bigger than RAM. - APIs: pagination, rate limits, retries with backoff, idempotent writes.
- Data transforms: dedup, group, merge, join two lists of records.
- Light algorithms: dictionaries and sets, sorting, sliding windows, merging intervals, top-k with a heap. Rarely graphs or dynamic programming.
- Testing: can you write a few good asserts or pytest cases for your own code?
How to approach a coding question
- Clarify input and output. Types, sizes, can it be empty, what to do with bad records.
- Write the signature and one example first. It forces precision.
- Start simple and correct, then improve. Say the complexity.
- Handle the edge cases explicitly: empty input, duplicates, malformed lines, ties.
- Test it. Write two or three asserts, including an edge case. Interviewers notice when you test without being asked.
- Talk about production: "In a pipeline I'd log the bad lines to a quarantine file and emit a metric."
Python that reads like a data engineer wrote it
- Use
csv,json,datetime,collections(defaultdict,Counter),itertools(islice,groupby) andheapqfrom the standard library before reaching for pandas. - Prefer generators for anything row-by-row, and return plain data structures.
- Inject dependencies (the HTTP call, the clock,
sleep) so the code is testable. - Use
datetimewith time zones (datetime.fromisoformat,timezone.utc) and never compare naive and aware datetimes. - Don't use floats for money. Use integer cents or
decimal.Decimal.
Practice
Every question has a Try it in the Python playground button: write your solution in the browser and press Run tests to check it against the question's tests. Python runs locally in your browser (Pyodide), so nothing is sent anywhere, and a runaway loop is stopped after 10 seconds. The reference solutions are checked against the same tests in CI.
- Read a large CSV in fixed-size batches with a generator
- Keep the latest version of each record
- Find missing and empty date partitions from object storage keys
- Parse a fixed-width file with a layout spec and a reject list
- Flatten nested JSON records into rows
- An idempotent batch upsert writer
- Fetch every page from a flaky paginated API
- Count HTTP status codes per path from raw log lines
- Detect anomalies in daily row counts with a robust baseline
- Detect schema drift between two batches of records
- Extract table lineage from SQL statements
- Top-k items from a stream with a heap
- Total downtime from overlapping incident windows