Quality gate: days with order volume outside bounds
Pandas data engineering interview problem. Difficulty: intermediate. Pattern: Data Quality. About 15 minutes. Part of the Pro drill bank.
A data quality gate that checks the row count of a whole table can pass while a single day is broken. If 1 day has far fewer orders than normal, the total can still look fine. Finance wants the check per day: a day with too few orders is probably a loading problem and not a real quiet day.
The tab gives you several pandas tables, including df_orders. Each order has a created_at text such as 2026-08-01 10:15:00. Take the date part of it (the first 10 characters) as order_date, and count the orders for each day as orders. Keep only the days where orders is below 8. These are the days that would fail a minimum of 8 orders per day. Return order_date and orders, sorted by order_date, with a clean index, and store it in result. The editor starts with result = df_orders.head(20). Change it to build your answer.
Requirements
- Make order_date from the date part of created_at.
- Count the orders for each order_date as orders.
- Keep only the days where orders is below 8.
- Return order_date and orders, sorted by order_date, with a clean index, in result.
Constraints
- order_date has no time part. It is only the date.
- orders is the number of order rows for that day.
- The limit is below 8. A day with exactly 8 orders passes the gate and is not returned.
Topics: data-quality, row-count, groupby, pandas.
More interview problems · All interview problems · Learn data engineering
Quality gate: days with order volume outside bounds
Production ticket: expect_row_count_between, run per day instead of once for the whole table.
The single-number row-count gate from Learn only checks the whole table. Finance wants it per day: a day with too few orders is a suspiciously quiet warehouse, not a real slow Tuesday. From `df_orders`, group by `order_date` (the date part of `created_at`). Count orders per day as `orders`. Keep only days where `orders` is below 8 (min_n) - the days that would fail this gate. Sort by `order_date`. Assign `result`.