Two Sigma·Data Scientist·Technical Phone Screen
- Given trips and zones datasets, join them on pickup zone, then compute median trip speed (mph) per borough and hour of day. Filter to trips where duration is between 1 and 120 minutes and speed is between 1 and 80 mph. Return the top 3 (borough, hour) pairs by median speed, breaking ties by borough then hour alphabetically.
- For Manhattan pickups between midnight and 5am, find the 3 taxi IDs with the highest 95th percentile trip duration in minutes. Break ties by taxi_id ascending. Define clearly how you compute the 95th percentile.
- Write the full pandas implementation for the above analyses in O(n log n) or better. Requirements: no row-level Python loops, parsed datetime dtypes, a single join performed once, categorical dtype for borough, and indexing on pickup_ts for time filtering.
- Justify two specific memory or performance optimizations in your implementation, such as downcasting numeric columns or doing groupby-agg in a single pass instead of multiple passes.
“The filtering part seemed easy but I almost forgot to convert duration to hours before computing speed.”