orders has order_id, customer_id and amount; customers has customer_id and segment. Write enrich_orders(orders, customers) that returns a tuple (enriched, orphan_order_ids):
- •
enriched — exactly one row per order, in the same order as orders, with columns order_id, customer_id, amount, segment. - •An order whose customer is in
customers gets that customer's segment as it is — including a missing segment, which stays missing. - •An order whose customer is not in
customers (including a missing customer_id) gets the segment "unknown". - •
orphan_order_ids — the sorted list of order_ids whose customer is not in customers.
customers is supposed to have one row per customer_id. If any customer_id appears more than once, don't pick one: raise a `ValueError`.
Python 3.13 in your browser — the standard library plus pandas and numpy; no pip installs.