Pandasdrill

Level 7: Interview cases Exercise 94 of 102

New customers per month

A pandas exercise from Pandasdrill. Solve it with a Python editor in your browser running real pandas, and it is checked the moment you submit.

The task

Growth asks how many customers placed their first ever order in each month. Count every order, whatever its status. Return the columns `month` (text like `2024-01`) and `customers`, in calendar order, with only the months in which someone ordered for the first time.

What this exercise teaches

The earliest date per customer is their start month, and counting those gives the size of each monthly cohort. Counting distinct customers per month answers a different question, active customers, because it counts returning buyers again in every month they order.

A hint if you get stuck

First reduce the table to one row per customer: the date of their first order. Then count customers per month.

Try it now, free, no account needed

Your first 8 exercises on Pandasdrill are free. Open it on the practice page, solve it, and get instant feedback with a hint. A free account adds the worked solution; Pro unlocks every exercise, timed mode and the certificate.

Open this exercise

More exercises in Interview cases