Learn practical skills, build real-world projects, and advance your career

Results with Merged Dataset

Q5: For all of the models that were produced in 2008 that are still being produced now, how much has the mpg improved and which vehicle improved the most?

Remember to use your new dataset, combined_dataset.csv

# load dataset
import pandas as pd
df = pd.read_csv('combined_dataset.csv')

1. Create a new dataframe, model_mpg, that contain the mean combined mpg values in 2008 and 2018 for each unique model

To do this, group by model and find the mean cmb_mpg_2008 and mean cmb_mpg for each.

model_mpg = df.groupby('model').mean()[['cmb_mpg_2008', 'cmb_mpg']]
model_mpg.head()