Practice / aggregations

Priciest Per Category

easy

The Daily Grind wants the headline price in each part of the menu.

You have the menu DataFrame:

Your task: return each category and a column top_price — the maximum price in that category.

Assign your answer DataFrame to result. Row order doesn't matter.

menuinput DataFrame

Schema
columntype
itemstring
categorystring
pricedouble
Sample rows
itemcategoryprice
Lattedrink5
Mochadrink6
Muffinfood3.5
Bagelfood3
Expected output shape
categorytop_price· 2 rows
Hint

groupBy("category") then agg(F.max("price").alias("top_price")).

Lesson refresher

This problem builds on Aggregations & groupBy (~7 min). Pop it open in a new tab if you want a quick recap.

Loading editor…
Hit Run to execute your code and see the output here.