Premium problem123. Distinct Customers per Month

Medium Locked

orders has columns order_id, customer_id and order_date (datetime).

Return a Series indexed by month (as a "YYYY-MM" string, named month) giving the number of distinct customers who ordered in that month, sorted by month. A customer ordering five times in March counts once for March.

Input

   order_id  customer_id order_date
0         1            1 2022-03-01
1         2            1 2022-03-15
2         3            2 2022-03-20
3         4            3 2022-04-02
4         5            3 2022-04-03

Output

month
2022-03    2
2022-04    1
dtype: int64

Premium problem

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

Implement solve(...)