groupbydatetimes

The full problem statement is available to Pro members.

preloaded fixtures

import pandas as pd
import numpy as np

watch_events = pd.DataFrame({
    "event_id": range(1, 13),
    "user": ["alice", "bob", "alice", "carol", "bob", "alice", "carol", "dave", "bob", "carol", "dave", "alice"],
    "genre": ["drama", "comedy", "drama", "docs", "comedy", "thriller", "docs", "drama", "comedy", "thriller", "drama", "drama"],
    "watch_date": pd.to_datetime(["2024-01-05", "2024-01-06", "2024-01-10", "2024-01-12", "2024-01-15", "2024-01-20", "2024-02-01", "2024-02-03", "2024-02-10", "2024-02-15", "2024-02-20", "2024-02-28"]),
    "minutes": [45, 30, 60, 20, 25, 50, 15, 55, 40, 35, 60, 50],
})

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

Pro problem

“Monthly watch hours”

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