groupbyratios

The full problem statement is available to Pro members.

preloaded fixtures

import pandas as pd
import numpy as np

trips = pd.DataFrame({
    "trip_id": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    "driver": ["alex", "alex", "sam", "sam", "alex", "jordan", "jordan", "sam", "alex", "jordan"],
    "city": ["SF", "SF", "NYC", "NYC", "SF", "LA", "LA", "NYC", "SF", "LA"],
    "fare": [12.5, 8.0, 20.0, 15.0, 9.5, 18.0, 22.0, 11.0, 14.0, 16.5],
    "surge": [1.0, 1.0, 1.5, 1.2, 1.0, 2.0, 1.5, 1.0, 1.3, 1.8],
    "distance": [3.2, 2.1, 5.5, 4.0, 2.8, 6.0, 7.2, 3.5, 3.8, 5.0],
})

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

Pro problem

“Fare per mile by city”

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