Prepare Taxi Driver Classification Data
Problem statement
Prepare train_drivers and test_drivers for a binary driver-classification task. Return both transformed datasets in one table, with all training rows first and all test rows second. Add dataset as the first column, using "train" or "test".
- Compute the mean non-null training
age. Fill missing ages in both datasets with that mean, then truncate every age to an integer. - For
car_modelandsecond_language, sort the distinct training strings in ascending order and encode them as0,1, and so on. Encode any value not seen in training as-1. - Compute the training mean and population standard deviation of
net_worth_of_tips. Standardize that column in both datasets with those training statistics and round it to five decimal places. If the training standard deviation is0, return0for every standardized tip value. - Encode
"A class"as0and"B class"as1. Preserve a null test label as null.
Keep all other values unchanged and return the declared columns in order.
Table schema
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.
train_drivers
Labeled training driver features.
| Column | Type | Nullable | Description |
|---|---|---|---|
| driver_idPK | Integer | No | — |
| car_model | Text | No | — |
| car_manufacture_year | Integer | No | — |
| days_since_inspection | Integer | No | — |
| age | Integer | Yes | — |
| experience | Integer | No | — |
| second_language | Text | No | — |
| rating | Decimal | No | — |
| net_worth_of_tips | Decimal | No | — |
| number_of_rejected_rides | Integer | No | — |
| number_of_upvotes | Integer | No | — |
| number_of_complaints | Integer | No | — |
| number_of_incidents | Integer | No | — |
| driver_class | Text | Yes | — |
test_drivers
Driver features to transform with training-only statistics.
| Column | Type | Nullable | Description |
|---|---|---|---|
| driver_idPK | Integer | No | — |
| car_model | Text | No | — |
| car_manufacture_year | Integer | No | — |
| days_since_inspection | Integer | No | — |
| age | Integer | Yes | — |
| experience | Integer | No | — |
| second_language | Text | No | — |
| rating | Decimal | No | — |
| net_worth_of_tips | Decimal | No | — |
| number_of_rejected_rides | Integer | No | — |
| number_of_upvotes | Integer | No | — |
| number_of_complaints | Integer | No | — |
| number_of_incidents | Integer | No | — |
| driver_class | Text | Yes | — |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| dataset | Text | No | — |
| driver_id | Integer | No | — |
| car_model | Integer | No | — |
| car_manufacture_year | Integer | No | — |
| days_since_inspection | Integer | No | — |
| age | Integer | No | — |
| experience | Integer | No | — |
| second_language | Integer | No | — |
| rating | Decimal | No | — |
| net_worth_of_tips | Decimal | No | — |
| number_of_rejected_rides | Integer | No | — |
| number_of_upvotes | Integer | No | — |
| number_of_complaints | Integer | No | — |
| number_of_incidents | Integer | No | — |
| driver_class | Integer | Yes | — |
Row order: must match exactly. Numeric tolerance: 0.00001.
Constraints
train_driversandtest_driversare both non-empty.- At least one training age is non-null.
- Training rows have
driver_classequal to"A class"or"B class". - Test labels may be null.
- Every numeric input is finite.
- Result row order is exact.
Source note: The screenshot is a prompt-only crop of the reported driver-performance schema; solution commentary is not shown.