
Drivers without rides
mediumDrivers without rides
Uber Pandas Interview Question
Uber's driver onboarding team follows up with people who signed up to drive but have not given a ride yet.
Using the drivers and rides DataFrames, find every driver with no rides, showing their driver_id and driver_name. Assign the answer to result.
Asked of
- Data Analyst
- Product Analyst
- Business Analyst
- Analytics Engineer
- Data Scientist
driversDataFrame10 rows
| Column Name | Type |
|---|---|
| driver_id | int64 |
| driver_name | str |
| vehicle_type | str |
| joined_date | str |
ridesDataFrame20 rows
| Column Name | Type |
|---|---|
| ride_id | int64 |
| driver_id | int64 |
| city | str |
| requested_at | str |
| fare | float64 |
| rating | float64 |
driversExample Input
| driver_id | driver_name | vehicle_type | joined_date |
|---|---|---|---|
| 305 | Elena Petrova | Black | 2019-11-15 |
| 306 | Sam Okoye | UberX | 2022-07-30 |
| 307 | Priya Iyer | Comfort | 2021-12-05 |
| 308 | Noah Fischer | Black | 2020-05-22 |
| 309 | Jordan Ellis | UberX | 2024-02-14 |
| 310 | Carmen Diaz | Black | 2023-10-01 |
ridesExample Input
| ride_id | driver_id | city | requested_at | fare | rating |
|---|---|---|---|---|---|
| 7001 | 301 | Chicago | 2024-06-03 08:12:00 | 18.4 | 5 |
| 7002 | 302 | Chicago | 2024-06-03 08:40:00 | 32.1 | 4 |
| 7003 | 303 | Austin | 2024-06-03 09:05:00 | 54.75 | 5 |
| 7004 | 304 | Austin | 2024-06-03 09:30:00 | 12.9 | NULL |
| 7005 | 301 | Chicago | 2024-06-03 11:15:00 | 21.6 | 4 |
| 7006 | 305 | Seattle | 2024-06-03 12:02:00 | 87.2 | 5 |
| 7007 | 306 | Seattle | 2024-06-03 12:45:00 | 16.3 | 3 |
| 7008 | 302 | Chicago | 2024-06-03 13:20:00 | 27.8 | NULL |
| 7009 | 307 | Austin | 2024-06-03 14:10:00 | 41 | 4 |
| 7010 | 303 | Austin | 2024-06-03 15:35:00 | 63.25 | 5 |
| 7011 | 304 | Austin | 2024-06-03 16:05:00 | 14.2 | 2 |
| 7012 | 308 | Seattle | 2024-06-03 17:40:00 | 95.6 | 4 |
Example Output
| driver_id | driver_name |
|---|---|
| 309 | Jordan Ellis |
| 310 | Carmen Diaz |
Explanation
Drivers 309 and 310 have no rides in the example, so they are returned. Drivers 305 to 308 each gave at least one ride, so they are left out.
The example above is a small slice of the data. Your code runs against the full DataFrames.
Company
Uber
Difficulty
medium
Topic
joins
Language
Pandas
Your code
Loading Python in the background. You can start writing.