6. Selecting, Filtering, and Sorting
6.3 Sorting and Top-N
df.sort_values("amount", ascending=False)
df.sort_values(["city", "amount"], ascending=[True, False])
df.nlargest(3, "amount")
df.nsmallest(3, "delivery_mins")
Worked example. Amir sorts by delivery_mins ascending to find the fastest fictional trips — Pune Hinjewadi-style 8 minutes for Shahrukh.
Practice task
Show Cancelled + Returned rows sorted by amount descending. Then show the top 3 Delivered amounts with nlargest.
Thodkyaat sangaycha tar (quick recap)
[]/loc/ilocfor select- Masks need parentheses with
&| isin,between,sort_values,nlargest
Samajla ka? Aata pudhe jaauya GroupBy and aggregations.