Sessionize Checkout Events and Build an Ordered PayPal Funnel

Last updated: November 29, 2026

Quick Overview

Given a pandas DataFrame of buyer events (buyer_id, ts, event), split each buyer's events into sessions separated by more than 30 minutes of inactivity, then report how many sessions reach each step of the PayPal checkout funnel in order.

PayPal
Data Manipulation (SQL/Python)
Data Scientist
PayPal
November 29, 2026
Data Scientist
Take-home Project
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


Given a pandas DataFrame of buyer events (buyer_id, ts, event), split each buyer's events into sessions separated by more than 30 minutes of inactivity, then report how many sessions reach each step of the PayPal checkout funnel in order.

The PayPal Checkout team watches the path from cart view to button click, login, review and payment completion, and conversion only makes sense per session. This take-home style task checks vectorized sessionization with diff and cumsum, ordered funnel logic rather than simple event counts, and clear definitions.

What the Interviewer Expects
  • Sort by buyer and time, then create session ids with diff and cumsum
  • Split sessions before filtering out non-funnel events
  • Require steps to happen in order within a session
  • Report both share of all sessions and step-to-step conversion
  • State definitions (gap length, what counts as the start)
Key Topics to Cover
sessionization
pandas groupby
funnel analysis
diff and cumsum
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you vectorize the ordered-depth calculation for 500 million events?
  • Should a session that starts at login (deep link from an email) count in the denominator?
  • How would you attribute a payment that completes 40 minutes after the click?
  • How would you split this funnel by guest checkout versus logged-in buyers?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Events: buyer_id, ts (datetime), event. Funnel steps in order: cart_view, paypal_button_click, login, review, payment_complete. A session ends after more than 30 minutes without any event, inc...

Approach

Session ids come from groupby().diff(): a new session starts when the gap is missing (first event) or exceeds 30 minutes, and a global cumsum over that boolean gives unique ids. Then keep funnel e...


Submit Your Answer
Markdown supported