FastPrepBuild Taxi Driver Performance Features
Problem · Database

Build Taxi Driver Performance Features

EasyCapital One logoCapital OneNEW GRADOA

Problem statement

Build one performance-feature row for every driver using drivers, cars, and the four ride partitions rides_1 through rides_4.

Use 2023-04-15 as today. Join each driver to the assigned car and return the result columns in the declared order.

  • days_since_inspection is the calendar-day difference between 2023-04-15 and last_inspection_date.
  • experience is 2023 - started_driving_year.
  • number_of_rejected_rides counts rides whose status is exactly "Rejected by the driver".
  • number_of_upvotes sums all true values across the four upvote columns.
  • number_of_complaints and number_of_incidents count true values in their corresponding ride columns.

Concatenate all four ride partitions before aggregation. Retain drivers with no rides and set all four ride-derived counts to 0.

Table schema

Pandas

Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.

drivers

Driver attributes as of 2023-04-15.

ColumnTypeNullableDescription
driver_idPKIntegerNo
car_idIntegerNo
ageIntegerYes
started_driving_yearIntegerNo
second_languageTextNo
ratingDecimalNo
net_worth_of_tipsDecimalNo
driver_classTextNo

cars

Car attributes and inspection dates.

ColumnTypeNullableDescription
car_idPKIntegerNo
modelTextNo
manufacture_yearIntegerNo
last_inspection_dateDateNo

rides_1

Ride partition 1.

ColumnTypeNullableDescription
ride_idPKIntegerNo
driver_idIntegerNo
dateDateNo
statusTextNo
car_clearness_upvote_givenBooleanNo
politeness_upvote_givenBooleanNo
communication_upvote_givenBooleanNo
punctuality_upvote_givenBooleanNo
complaint_givenBooleanNo
incident_occurredBooleanNo

Foreign key: driver_id drivers(driver_id)

rides_2

Ride partition 2.

ColumnTypeNullableDescription
ride_idPKIntegerNo
driver_idIntegerNo
dateDateNo
statusTextNo
car_clearness_upvote_givenBooleanNo
politeness_upvote_givenBooleanNo
communication_upvote_givenBooleanNo
punctuality_upvote_givenBooleanNo
complaint_givenBooleanNo
incident_occurredBooleanNo

Foreign key: driver_id drivers(driver_id)

rides_3

Ride partition 3.

ColumnTypeNullableDescription
ride_idPKIntegerNo
driver_idIntegerNo
dateDateNo
statusTextNo
car_clearness_upvote_givenBooleanNo
politeness_upvote_givenBooleanNo
communication_upvote_givenBooleanNo
punctuality_upvote_givenBooleanNo
complaint_givenBooleanNo
incident_occurredBooleanNo

Foreign key: driver_id drivers(driver_id)

rides_4

Ride partition 4.

ColumnTypeNullableDescription
ride_idPKIntegerNo
driver_idIntegerNo
dateDateNo
statusTextNo
car_clearness_upvote_givenBooleanNo
politeness_upvote_givenBooleanNo
communication_upvote_givenBooleanNo
punctuality_upvote_givenBooleanNo
complaint_givenBooleanNo
incident_occurredBooleanNo

Foreign key: driver_id drivers(driver_id)

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
driver_idIntegerNo
car_modelTextNo
car_manufacture_yearIntegerNo
days_since_inspectionIntegerNo
ageIntegerYes
experienceIntegerNo
second_languageTextNo
ratingDecimalNo
net_worth_of_tipsDecimalNo
number_of_rejected_ridesIntegerNo
number_of_upvotesIntegerNo
number_of_complaintsIntegerNo
number_of_incidentsIntegerNo
driver_classTextNo

Row order: any order is accepted. Numeric tolerance: 0.

Constraints

  • Every driver references exactly one row in cars.
  • Every ride references a row in drivers.
  • Every date is a valid ISO calendar date no later than 2023-04-15.
  • started_driving_year is no later than 2023.
  • age may be null; all other driver and car fields are non-null.
  • Result row order is ignored.

Source note: The screenshot is a prompt-only crop showing the fixed date and driver schema; solution commentary is not shown.

More Capital One problems