Skip to interview prep
Apexed

4. Top customer each month

MediumPandas & NumPy

Rows have month (like "2026-01"), customer and amount. For each month, return the customer with the highest total spend. Break ties by customer name. Return [month, customer, total] sorted by month.

Input rows arrive as a list of dictionaries; build a DataFrame with pd.DataFrame(rows).

Example 1

Input: …
Output: [['2026-01', 'ana', 120], ['2026-02', 'bo', 90]]

Constraints

  • Totals are integers

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 3 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Top customer each month — coding interview practice — Apexed