Data Cleaning Reps

← All exercises

Collapse drive labels into groups

IntermediateCASE + LIKEVehicle fuel economy (FuelEconomy.gov, model years 2010–2027)

Group drive into AWD/4WD (anything mentioning All-Wheel or 4-Wheel), FWD, RWD, and Other. Return group and count, largest first.

Hint

Check the 4-Wheel / All-Wheel patterns first with LIKE '%4-Wheel%' and LIKE '%All-Wheel%'.

Same question in Excel / Google Sheets

=IF(OR(ISNUMBER(SEARCH("4-Wheel",F2)),ISNUMBER(SEARCH("All-Wheel",F2))),"AWD/4WD",IF(LEFT(F2,5)="Front","FWD",IF(LEFT(F2,4)="Rear","RWD","Other")))

Download the CSV from the datasets page. Column letters assume the CSV opens with its header in row 1.

Tip: Ctrl+Enter (⌘+Enter on Mac) checks your answer. Everything runs in your browser; nothing you type is sent anywhere.

← How many ways to say 'drive type'?Automatic or manual? →