Uber Revenue Loss from Cancellations
Problem
**[Asked at Uber]**
Calculate completed revenue, lost revenue (from cancelled orders), and the
**loss percentage** (cancelled / total) rounded to 2 dp.
Return a single row with `completed_revenue`, `lost_revenue`, `loss_pct`.
Input data
Example rows — the live problem includes the full dataset.
orders
| order_id | fare | status |
|---|---|---|
| 1 | 15.50 | completed |
| 2 | 25.00 | completed |
| 3 | 18.00 | cancelled |
| 4 | 22.50 | completed |
| 5 | 30.00 | cancelled |
Expected output
Your answer should return 1 row with the columns completed_revenue, lost_revenue, loss_pct.
Starter code (Pandas (Python))
import pandas as pd
def revenue_loss(orders: pd.DataFrame) -> pd.DataFrame:
# Your code here
return ordersSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock