groupbyagg

The full problem statement is available to Pro members.

preloaded fixtures

import pandas as pd
import numpy as np

deliveries = pd.DataFrame({
    "delivery_id": range(1, 11),
    "city": ["Chicago", "Chicago", "Chicago", "Austin", "Austin", "Denver", "Chicago", "Austin", "Chicago", "Denver"],
    "cuisine": ["mexican", "asian", "mexican", "salads", "pizza", "breakfast", "asian", "pizza", "mexican", "breakfast"],
    "placed_at": pd.to_datetime(["2024-01-10 18:20", "2024-01-10 19:05", "2024-01-11 12:30", "2024-01-11 13:10",
                                  "2024-01-12 20:00", "2024-01-12 08:45", "2024-01-13 19:40", "2024-01-14 18:15",
                                  "2024-01-15 18:55", "2024-01-16 09:05"]),
    "minutes": [32, 41, 27, 22, 55, 19, 38, 48, 30, 24],
    "total": [24.50, 38.00, 18.75, 15.00, 42.20, 12.40, 29.90, 51.00, 22.10, 14.00],
    "tip": [4.00, 6.00, 2.50, 3.00, 5.00, 2.00, 4.50, 8.00, 3.50, 1.50],
})

Guest mode · solve history stays on this device; code isn’t saved. Sign in to save future work

Pro problem

“Tip percentage by cuisine”

This is one of the real interview questions in Pro. Try Pro free for 7 days to unlock it and everything below:

  • 293 interview-grade problems across SQL, Python & pandas
  • 104+ real-world SQL problems: SaaS retention, fintech ledgers, supply chain, recursive CTEs
  • 18 company interview packs (Amazon, Meta, Google, Uber and more)
  • AI "explain my mistake" tutor and mock interviews
  • Use QueryLab inside Claude, Cursor & other AI assistants

// built for real interview rounds

Practice the patterns 18 top companies test

329 problems · 36 free forever · 293 unlocked with Pro

Card required. Then $12/month. Cancel before your trial ends and you pay nothing.

or keep practicing free problems →

Secure checkout by Paddle · instant access · cancel anytime from your account