Demand To Settlement Turnaround By Firm Cohort In Pandas
Last updated: November 29, 2026
Quick Overview
From a case event log, compute for each law firm and monthly cohort of first demand sent: the number of cases, how many settled, the median days from first demand to settlement, and the share settled within 90 days, only for cohorts old enough to judge.
EvenUp
November 29, 20260
0
0 solved
From a case event log, compute for each law firm and monthly cohort of first demand sent: the number of cases, how many settled, the median days from first demand to settlement, and the share settled within 90 days, only for cohorts old enough to judge.
Speed to settlement is one of the outcomes EvenUp's customers care most about, and analytics teams report it by firm and cohort. The exercise tests event log reshaping, cohort logic and recognizing right-censoring so recent cohorts do not look artificially fast or slow.
What the Interviewer Expects
- Reduces the log to first demand and first settlement per case
- Defines cohorts by first demand month
- Drops or flags impossible orderings (settlement before demand)
- Handles censoring for immature cohorts
- Explains why the median over settled cases alone is biased
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 compare turnaround before and after a firm adopted a new product without being fooled by mix shifts?
- How would a Kaplan-Meier estimate change your reported median?
- Cases can reopen after settlement falls through: how do you model that?
- How would you write this in SQL for a dashboard?
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(case_id, firm_id, event_type, event_ts) where event_type is demand_sent or settled. A case can have several demands (a revised demand after new records) and should be measured from the ...
Approach
Take the earliest timestamp per case and event type, pivot to columns, keep cases with a demand, null out settlements that precede the demand, and compute days. A cohort is mature when its last possib...