Practice / spark mental model

The Filter That Did Nothing

easy

A colleague at The Daily Grind wrote some code to list the large drinks along with what the customer actually paid: the price plus the tip. It errors. Fix it; don't start again from scratch.

You have the orders DataFrame:

Your task: return order_id, drink, and paid (where paid is price + tip) for every order with size "large".

Assign your answer DataFrame to result. Row order doesn't matter, and paid is compared with a float tolerance.

ordersinput DataFrame

Schema
columntype
order_idlong
drinkstring
sizestring
pricedouble
tipdouble
Sample rows (first few)
order_iddrinksizepricetip
1001oat lattelarge6.51
1002drip coffeesmall30
1003caramel macchiatolarge7.252
1004flat whitemedium51.5
1005cold brewlarge5.50.5
1006espressosmall2.50.75
1007mochalarge6.750.25
1008lattemedium5.252
1009gold-dust affogatosmall6.50.75
1010barrel-aged cold brewlarge60.5
Expected output shape
order_iddrinkpaid· 5 rows
›Hint

Every transformation returns a new DataFrame and leaves the old one alone. Two lines here return something and throw it away. Give each one a name, and build result from the last name.

›Lesson refresher

This problem builds on Nothing Runs Until You Ask (~4 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.