Ordered Marketplace Funnel from Raw Events in Python

Last updated: November 29, 2026

Quick Overview

Given a DataFrame of Facebook Marketplace events (user_id, event, ts), write Python that computes how many users completed search, then view_listing, then message_seller in that order, with step-to-step conversion.

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Given a DataFrame of Facebook Marketplace events (user_id, event, ts), write Python that computes how many users completed search, then view_listing, then message_seller in that order, with step-to-step conversion.

Funnel questions in Meta pandas rounds test whether a candidate respects event order instead of just checking that each event happened. Marketplace is a natural setting because buyers browse heavily before messaging. The interviewer checks ordered matching, users who skip steps, and a clean summary table.

What the Interviewer Expects
  • Explains why counting users with each event is not an ordered funnel
  • Sorts events per user with a stable sort
  • Implements greedy ordered matching to find the deepest step
  • Produces users reached and conversion from previous step and from start
  • Discusses time windows and complexity
Key Topics to Cover
Funnel analysis
pandas groupby
Ordered events
Greedy matching
Conversion rates
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 require all steps within 24 hours of the search?
  • How would you vectorize this for very large data?
  • How would you count funnels per session rather than per user?
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 has user_id, event, ts. Steps: ["search", "view_listing", "message_seller"]. A user reaches step kk if there exist events for steps 1..kk in increasing time order. Other event types...

Approach

Counting users with each event overstates the funnel: a user who messaged a seller from a notification without searching would count as converting. Instead, for each user scan events in time order wit...


Submit Your Answer
Markdown supported