Verified References on Each Order
Problem
Three DataFrames describe a platform's members, the reference contacts they listed, and the orders they placed.
`member` (`member.csv`): `member_id`, `member_name`, `email` — one registered member per row.
`reference` (`reference.csv`): `member_id`, `ref_name`, `ref_email` — each row is a reference contact a member listed. A reference is **verified** when its `ref_email` matches the `email` of some registered member.
`order` (`order.csv`): `order_id`, `total`, `member_id` — one order placed by a member.
For each order, report `order_id`, the ordering member's `member_name`, the order `total`, the number of references that member listed (`refs_cnt`), and how many of those references are verified (`verified_cnt`). Return the rows ordered by `order_id`.
**Example**
If a member listed 3 references and 2 of their `ref_email`s belong to registered members, that order shows `refs_cnt = 3` and `verified_cnt = 2`.
Input data
Example rows — the live problem includes the full dataset.
| member_id | member_name | |
|---|---|---|
| 1 | Noa | noa@mail.io |
| 2 | Ravi | ravi@mail.io |
| 3 | Sol | sol@mail.io |
| member_id | ref_name | ref_email |
|---|---|---|
| 1 | r1 | ravi@mail.io |
| 1 | r2 | ghost@mail.io |
| 2 | r3 | sol@mail.io |
| order_id | total | member_id |
|---|---|---|
| 10 | 200 | 1 |
| 11 | 150 | 2 |
Expected output
Your answer should return 2 rows with the columns order_id, member_name, total, refs_cnt, verified_cnt.
Starter code (Pandas (Python))
import pandas as pd
def verified_references_per_order(member: pd.DataFrame, reference: pd.DataFrame, order: pd.DataFrame) -> pd.DataFrame:
# Your code here
return memberSolve 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