A payments file is too large for memory, so it's read with pd.read_csv(path, chunksize=…), which yields one DataFrame per chunk. totals_by_customer(chunks) receives that iterator; every chunk has the columns customer_id and amount.
Return a dict customer_id -> total amount:
- •a customer's rows can be spread across many chunks; add them all up;
- •a missing amount (
NaN) counts as 0, and a customer whose amounts are all missing still appears with 0.0; - •totals are plain Python
floats, rounded to 2 decimal places once, at the end.
The chunks can only be read once, and you must work through them one at a time: never hold more than one chunk in memory. The tests feed a stream that fails if earlier chunks are still being held.
Python 3.13 in your browser — the standard library plus pandas and numpy; no pip installs.