Next-Day Order Confirmations
Problem
A retailer stores orders in a DataFrame `orders` with columns `order_ref`, `customer_id`, `placed_at` (datetime string), and follow-up phone calls in a DataFrame `callbacks` with columns `callback_ref`, `order_ref`, `outcome`, `called_at` (datetime string).
Find the `customer_id` of every customer whose order was confirmed exactly one calendar day after it was placed: the matching callback must have `outcome` equal to 'Confirmed', and its call date must be exactly one day after the order's placement date (compare dates only, ignore the time of day).
Return a single column `customer_id`, ordered ascending.
Input data
Example rows — the live problem includes the full dataset.
| order_ref | customer_id | placed_at |
|---|---|---|
| 125 | 6312 | 2024-06-14 09:30:00 |
| 433 | 6477 | 2024-07-09 08:15:00 |
| 234 | 6190 | 2024-08-20 10:00:00 |
| callback_ref | order_ref | outcome | called_at |
|---|---|---|---|
| 1 | 125 | Confirmed | 2024-06-15 08:30:00 |
| 2 | 433 | Declined | 2024-07-10 10:45:00 |
| 4 | 234 | Confirmed | 2024-08-21 09:30:00 |
Expected output
Your answer should return 2 rows with the columns customer_id.
Starter code (Pandas (Python))
import pandas as pd
def next_day_order_confirmations(orders, callbacks) -> pd.DataFrame:
# Your code here
return ordersSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock