← Lyft Interview Insights

Lyft·Data Scientist·Technical Phone Screen·Senior

Senior
Sep 2025Remote

Summary

Lyft data scientist interview that was basically a full SQL gauntlet with schema handed to you upfront. Four tasks, progressively harder, and the rolling window piece at the end is where things got uncomfortable.

Questions Asked (4)

Q1

Given an events table and an orders table, compute for each city and date: unique users with at least one impression, completed orders using the latest status per order, conversion rate, and a 7-day rolling conversion rate per city.

Product Analytics & MetricsData Modeling
Author's notes

The funnel part was fine but the rolling window is where I got tripped up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Break the problem into two independent aggregations: one for unique users with impressions per city/date from the events table, and one for completed orders per city/date from the orders table using the latest status per order. Then join these aggregates on city and date, compute the daily conversion rate, and finally apply a 7-day rolling window per city to get the rolling conversion rate.

Pro tip: Clarify the definition of 'completed orders' and how to handle orders with multiple status updates—using the latest status per order is key, but also consider timezone alignment between events and orders to avoid mismatched dates.

1. Aggregate impressions per city/date

From the events table, filter for impression events, then count distinct users grouped by city and date. Ensure you handle any duplicate impressions per user per day.

2. Aggregate completed orders per city/date

From the orders table, first determine the latest status per order (e.g., using a window function or subquery), then filter for completed orders and count them grouped by city and date.

3. Join and compute daily conversion rate

Join the two aggregates on city and date (using a full outer join to include days with only impressions or only orders), then compute conversion rate as completed orders divided by unique users with impressions, handling division by zero.

4. Calculate 7-day rolling conversion rate

For each city, order by date and compute a rolling sum of completed orders and unique users over the past 7 days (including current day), then divide to get the rolling conversion rate. Ensure the window is correctly defined (e.g., ROWS BETWEEN 6 PRECEDING AND CURRENT ROW).

Key Points to Mention

  • Use DISTINCT COUNT for unique users with impressions to avoid double-counting.
  • Determine the latest status per order using a window function like ROW_NUMBER() OVER (PARTITION BY order_id ORDER BY updated_at DESC).
  • Handle missing dates by using a full outer join or generating a date spine to ensure rolling calculations are accurate.
  • Define conversion rate as completed orders / unique users with impressions, and consider if the denominator should be users who had at least one impression on that day.
  • For rolling 7-day conversion, aggregate the numerator and denominator separately over the window before dividing, rather than averaging daily rates.
  • Be mindful of timezone consistency between events and orders to align dates correctly.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

For each supplier and date in the same window, compute demand as unique non-cancelled orders created on that date, then compute fill rate as min(demand, units_available) divided by demand. Handle missing inventory dates by defaulting units_available to zero.

Data ModelingProduct Analytics & Metrics
Author's notes

The NULLIF trick for division by zero I knew cold.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: define the date window, what constitutes a non-cancelled order, and how to handle missing inventory dates. Then outline a step-by-step SQL or pandas approach that aggregates orders by supplier and date, joins with inventory data, and computes fill rate with proper null handling.

Pro tip: Mention that you would validate the results by checking edge cases, such as days with zero demand (fill rate undefined) and suppliers with no inventory records, to ensure the metric is robust and interpretable.

1. Clarify definitions and assumptions

Confirm the date window, the definition of a non-cancelled order, and whether demand counts unique orders or unique order items. Also clarify if units_available is per supplier per date.

2. Aggregate demand

Filter orders to non-cancelled and within the date window, then group by supplier and order date to count unique orders (or order IDs) as demand.

3. Prepare inventory data

Select supplier, date, and units_available from the inventory table. Ensure all dates in the window are represented, possibly by generating a date spine and left joining inventory, defaulting missing units_available to 0.

4. Join and compute fill rate

Left join demand with inventory on supplier and date. Compute fill rate as min(demand, units_available) / demand, handling cases where demand is 0 (e.g., set fill rate to NULL or 1).

5. Validate and interpret

Check for anomalies such as fill rates >1 or negative values. Discuss how to interpret fill rate and potential business implications.

Key Points to Mention

  • Unique order counting: use COUNT(DISTINCT order_id) to avoid double-counting if orders have multiple line items.
  • Handling missing inventory dates: use a date spine or COALESCE to default units_available to 0.
  • Edge case: demand = 0 leads to division by zero; decide whether to exclude, set to NULL, or define fill rate as 1.
  • Window functions or subqueries to ensure all supplier-date combinations are considered.
  • Data quality checks: ensure no duplicate inventory records per supplier-date, and validate that units_available is non-negative.
  • Business context: fill rate measures ability to meet demand; low fill rate may indicate supply chain issues.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

If an order is created on one date but completes on a later date, which date should it contribute to for demand vs. completed orders? Explain your definition and justify it.

Product Analytics & MetricsAdaptability & Ambiguity
Author's notes

More conceptual than I expected at this point in the interview.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the choice depends on the business question: demand should be attributed to the order creation date to reflect when customer intent occurred, while completed orders should be attributed to the completion date to reflect when revenue was realized. Justify by aligning with Lyft's operational and financial reporting needs, and acknowledge that both metrics serve different purposes.

Pro tip: Mention that you would align with finance and operations stakeholders to ensure consistency with revenue recognition and driver incentive periods, showing cross-functional awareness.

1. Clarify the business context

Ask whether the metric is used for demand forecasting, driver incentives, or financial reporting, as the appropriate date depends on the purpose.

2. Define demand attribution

Attribute demand to the order creation date because it captures when the customer requested a ride, which is critical for supply planning and marketing effectiveness.

3. Define completed order attribution

Attribute completed orders to the completion date because revenue is recognized upon ride completion, and it reflects actual service delivery.

4. Justify with business impact

Explain that using creation date for demand helps predict future needs, while completion date for completed orders ensures accurate financial reporting and driver payouts.

5. Address edge cases and alignment

Discuss handling of cancellations, long-duration rides, and time zones, and emphasize the need for consistent definitions across teams.

Key Points to Mention

  • Demand should be attributed to order creation date to reflect customer intent and enable accurate supply-demand matching.
  • Completed orders should be attributed to completion date to align with revenue recognition and driver earnings.
  • Different metrics serve different purposes; there is no single correct answer without business context.
  • Consistency with financial reporting standards (e.g., GAAP) and operational KPIs is crucial.
  • Edge cases like cancellations, refunds, and cross-day rides require clear handling rules.
  • Stakeholder alignment (finance, operations, product) ensures definitions are agreed upon and used consistently.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

Write SQL that handles duplicate rows in the orders table by selecting only the latest status per order using window functions. Then sketch the equivalent pandas code, including the rolling metric and safe division.

Data ModelingAlgorithms & Data Structures
Author's notes

ROW_NUMBER() partitioned by order_id ordered by status_updated_at descending, keep rank=1.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the table schema and what 'latest status' means (e.g., by timestamp or version). Then write a SQL query using ROW_NUMBER() partitioned by order_id and ordered by the timestamp descending, filtering for row number 1. For the pandas part, replicate the same logic using sort_values and groupby().head(1) or drop_duplicates, then demonstrate rolling metric with rolling() and safe division using np.where or a lambda.

Pro tip: Always mention that you would validate the deduplication by checking for duplicate order_ids after the operation, and discuss the trade-offs between window functions and other methods (e.g., self-join) in terms of performance and readability.

1. Clarify requirements and schema

Ask about the table structure, what defines 'latest' (timestamp, version, etc.), and whether there are ties. Confirm the expected output: one row per order with the latest status.

2. Write SQL with window function

Use ROW_NUMBER() OVER (PARTITION BY order_id ORDER BY updated_at DESC) to rank rows, then filter WHERE rn = 1. Alternatively, use RANK() or DENSE_RANK() if ties need special handling.

3. Translate to pandas

Sort the DataFrame by order_id and updated_at descending, then use groupby('order_id').head(1) or drop_duplicates(subset='order_id', keep='first'). Mention that sort_values is crucial for correctness.

4. Implement rolling metric and safe division

Use df.rolling(window=...).mean() (or other aggregation) to compute a rolling metric. For safe division, use np.where(denominator != 0, numerator/denominator, 0) or a custom function to avoid division by zero.

5. Validate and discuss trade-offs

Check that the result has unique order_ids and that the rolling metric behaves as expected. Discuss performance implications of window functions vs. pandas operations, and when to use each.

Key Points to Mention

  • Window functions: ROW_NUMBER, RANK, DENSE_RANK and their differences
  • Partitioning by order_id and ordering by timestamp descending
  • Pandas equivalents: sort_values, groupby, head, drop_duplicates
  • Rolling window calculations: rolling().mean(), min_periods, window size
  • Safe division techniques: np.where, fillna, or using a mask
  • Performance considerations: window functions vs. self-joins, pandas vectorization

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.