Revenue by calendar month

Data framesMedium11 min

Your task

Given orders with columns order_id, customer, amount, status and placed, sum amount for each calendar month. Return month as a YYYY-MM string and total, sorted by month ascending.

Examples

monthly_total(orders: dataframe) -> dataframe
Example 1
Inputmonthly_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
monthtotal
2024-01200.5
2024-02245.25
2024-0375.75