AnalystPath

Next-Day Order Confirmations

PandasEasyJunior level~10 min

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.

orders
order_refcustomer_idplaced_at
12563122024-06-14 09:30:00
43364772024-07-09 08:15:00
23461902024-08-20 10:00:00
callbacks
callback_reforder_refoutcomecalled_at
1125Confirmed2024-06-15 08:30:00
2433Declined2024-07-10 10:45:00
4234Confirmed2024-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 orders

Solve 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

Related Pandas questions