Premium problem132. Customers With at Least One Order

Medium Locked

customers has columns customer_id and name. orders has columns order_id and customer_id.

Return each customer who has placed at least one order, exactly once, with both original columns, sorted by customer_id and the index renumbered from 0.

A plain merge duplicates a customer once per order, which is the thing to avoid here rather than paper over with drop_duplicates afterwards.

Input

customers =
   customer_id name
0            1  Ann
1            2   Bo
2            3   Cy
orders =
   order_id  customer_id
0         1            1
1         2            1
2         3            1
3         4            3

Output

   customer_id name
0            1  Ann
1            3   Cy

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)