Ravindra BagaleCourses & study guides

17. Practice Exercises with Answer Hints

17.1 Warm-up Filters

Exercise A. Build a DataFrame with 8 rows across all six cities. Filter Delivered orders with amount ≥ ₹200. Sort by amount descending.

Hint A

Use (df["status"]=="Delivered") & (df["amount"]>=200) then sort_values("amount", ascending=False).

Exercise B. Show top 3 slowest deliveries with nlargest on delivery_mins.

Hint B

df.nlargest(3, "delivery_mins")[["order_id", "city", "delivery_mins"]].