Data Transformation and Processing Logic Questions
Implementing transformation logic: joins, aggregations, deduplication, pivoting/reshaping, and business-rule application over datasets. Covers writing correct and maintainable transformation code, handling edge cases in the transform layer, and preparing data for downstream consumption. Focuses on the logic of turning raw data into analytics-ready outputs.
Design and implement a streaming deduplication component that consumes a stream of (id, timestamp) events and reports whether each event is new or a duplicate within a bounded time window, using bounded memory (an LRU cache or a Bloom filter, your choice). Discuss the correctness trade-off of the approach you chose: can it produce false positives or false negatives, and what does that mean for events that get silently dropped or double-counted?
Discuss the options for parallelizing a CPU-bound data transformation in Python: threading, multiprocessing, vectorized numpy/pandas operations, and moving to a distributed framework like Dask or Spark. Explain why Python's GIL limits threading for CPU-bound work, and the practical costs (serialization overhead, memory duplication) of multiprocessing. Provide a small code sketch of a multiprocessing-based approach that preserves input order in its output.
Given a table (or DataFrame) of user events with a timestamp, derive session boundaries: a new session starts whenever the gap between consecutive events for the same user exceeds a configured timeout. Implement this both in SQL (using LAG/window functions and a running sum to assign session ids) and in pandas (as a reusable function), and return session id, start, end, and event count per session. Discuss how you handle unsorted input and timezone-aware timestamps.
In Python, implement a function that deduplicates a collection of in-memory records by a key (for example email address, case-insensitively). Provide two variants of the policy: (a) drop all but the most recent record for each key, and (b) merge duplicate records together (summing numeric fields, keeping the most recent value for everything else). Handle an empty input and a subset key that is entirely null.
Multiple data sources represent the same categorical attribute with different spellings or abbreviations (for example 'NY', 'New York', 'new_york', 'NYC' all meaning the same state or city). Describe a practical pipeline to detect, normalize, and maintain a mapping for these variants before merging datasets, including fuzzy matching, a maintained ruleset, and a human-in-the-loop step for ambiguous cases.
Unlock Full Question Bank
Get access to all 38 Data Transformation and Processing Logic interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.