Practice / aggregations

Basket Contents

medium

Waveform's merch store wants to see what each shopper is holding.

You have the cart DataFrame:

Your task: return each user_id and a column items — the distinct products in that user's cart, as an alphabetically sorted list.

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

cartinput DataFrame

Schema
columntype
user_idlong
itemstring
Sample rows (first few)
user_iditem
1Vinyl
1Tote
1Vinyl
1Sticker
1Hoodie
1Cap
1Poster
2Mug
2Pin
2Tee
Expected output shape
user_iditems· 2 rows
›Hint

F.collect_set("item") gathers the distinct items per group. Wrap it in F.sort_array(...) so the list comes back in a stable alphabetical order.

›Lesson refresher

This problem builds on One Row Per Group (~5 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.