Cheapest product in each category

Data framesMedium9 min

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) -> dataframe
Example 1
Inputcheapest_per_category(products)
products
skucategorypricestock
A-1tools9.9912
B-2tools24.50
C-3garden157
D-4garden153
E-5kitchen420
Output
categoryskuprice
gardenC-315
kitchenE-542
toolsA-19.99