Cheapest product in each category
Your task
Given products with columns sku, category, price and stock, return the single cheapest product per category, breaking ties by sku ascending. Return category, sku and price, sorted by category ascending.
Examples
cheapest_per_category(products: dataframe) -> dataframeExample 1
Input
cheapest_per_category(products)products
| sku | category | price | stock |
|---|---|---|---|
| A-1 | tools | 9.99 | 12 |
| B-2 | tools | 24.5 | 0 |
| C-3 | garden | 15 | 7 |
| D-4 | garden | 15 | 3 |
| E-5 | kitchen | 42 | 0 |
Output
| category | sku | price |
|---|---|---|
| garden | C-3 | 15 |
| kitchen | E-5 | 42 |
| tools | A-1 | 9.99 |