mergedate filteringgroupby

The full problem statement is available to Pro members.

preloaded fixtures

import pandas as pd

watch = pd.DataFrame({
    "account": ["a1", "a1", "a1", "a2", "a2", "a3", "a3"],
    "title": ["Deep Current", "Night Shift", "Deep Current", "Night Shift", "Deep Current", "Night Shift", "Night Shift"],
    "watched_on": pd.to_datetime([
        "2024-03-01", "2024-03-10", "2024-02-01", "2024-03-05", "2024-03-14", "2024-03-02", "2024-02-10",
    ]),
    "minutes": [120, 45, 300, 90, 60, 30, 400],
})

cancellations = pd.DataFrame({
    "account": ["a1", "a2", "a3"],
    "cancelled_on": pd.to_datetime(["2024-03-15", "2024-03-15", "2024-03-15"]),
})

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

Pro problem

“Watch time before cancelling”

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