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.
During feature or dataset preparation for a supervised model, a join can accidentally introduce label leakage: for example, joining in a table that contains information only available after the outcome is known, or a join that looks ahead in time. Describe common sources of this kind of leakage, how you would detect it automatically, and how you would design a rollback or re-computation process once leakage is found.
Some aggregations (sum, count) are associative and trivially parallelizable across a distributed dataset with a guaranteed deterministic result. Others, like median or percentile, are not. Discuss how you would compute an approximate percentile at scale with a mergeable, deterministic algorithm (for example a t-digest or histogram sketch), and separately, how you would implement a scalable approximate 'distinct count' (for example unique users in the last 30 days) using a structure like HyperLogLog, including the accuracy/memory trade-off of each.
Given a users table and a transactions table, write a SQL query using window functions to build a per-user feature/summary table in one pass: last transaction date, a rolling count of transactions in the past 30 days, a rolling average amount over the past 90 days, and days since signup. Explain how you handle a user who has never transacted.
Implement a reusable data-cleaning function that imputes missing values in a DataFrame: numeric columns filled with the column median, categorical columns filled with the mode (or a placeholder), with a configurable strategy per column type. The function should preserve original dtypes, not mutate the input in place, handle an empty DataFrame and a column that is entirely missing without raising an exception, and optionally add a boolean '<column>_imputed' flag so downstream consumers can tell which values were real versus imputed. Discuss how you would adapt this to a dataset too large to fit in memory.
Given a table of per-entity transactions (an entity id, an amount, and a timestamp), write a SQL query using window functions that computes a rolling N-day average or sum per entity per day, including days where the entity had no activity (rather than silently skipping them). Explain how you generate the calendar of dates needed for this and discuss the RANGE versus ROWS framing for the window.
Unlock Full Question Bank
Get access to all 34 Data Transformation and Processing Logic interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.