Data Cleaning Reps

← All exercises

Best combined MPG per year (EVs excluded)

Advancedwindow functionsVehicle fuel economy (FuelEconomy.gov, model years 2010–2027)

For each model year, return year, make, model and comb_mpg of the highest-comb_mpg record that is not an EV (atv_type <> 'EV'). Break ties by make then model A→Z. Order by year.

Hint

ROW_NUMBER() OVER (PARTITION BY year ORDER BY comb_mpg DESC, make, model), then keep row 1.

Same question in Excel / Google Sheets

Sort by year A→Z, comb_mpg Z→A, make, model; then Remove Duplicates on year (keeps the first row per year).

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.

← Same car, many rowsWhich rows are actually states? →