Running total of order value

Data framesMedium11 min

Your task

Given orders with columns order_id, customer, amount, status and placed, return a running total of amount in placed order as running, taking orders placed on the same day in order_id order. Return order_id and running, sorted by placed ascending and then order_id ascending.

Examples

running_total(orders: dataframe) -> dataframe
Example 1
Inputrunning_total(orders)
orders
order_idcustomeramountstatusplaced
1ada120.5paid2024-01-05
2bo80refunded2024-01-07
3ada45.25paid2024-02-11
4cy200paid2024-02-14
5bo15.75pending2024-03-02
6ada60paid2024-03-19
Output
order_idrunning
1120.5
2200.5
3245.75
4445.75
5461.5
6521.5