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
November 29, 20260
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
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- 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 ProblemsSample Answer
Clarify the Data
events has user_id, event, ts. Steps: ["search", "view_listing", "message_seller"]. A user reaches step if there exist events for steps 1.. 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...