<jupyter_start><jupyter_text>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`. You should've created this data file in the previous section: *Merging Datasets*.<jupyter_code># load dataset
import pandas as pd

df =pd.read_csv('combined_dataset.csv')<jupyter_output><empty_output><jupyter_text>1. Create a new dataframe, `model_mpg`, that contain the mean combined mpg values in 2008 and 2018 for each unique modelTo do this, group by `model` and find the mean `cmb_mpg_2008` and mean `cmb_mpg` for each.<jupyter_code>model_mpg = df.groupby('model').mean()[['cmb_mpg_2008','cmb_mpg']]
model_mpg.head()<jupyter_output><empty_output><jupyter_text>2. Create a new column, `mpg_change`, with the change in mpgSubtract the mean mpg in 2008 from that in 2018 to get the change in mpg<jupyter_code>model_mpg['mpg_change'] =model_mpg['cmb_mpg']-model_mpg['cmb_mpg_2008']
model_mpg.head()<jupyter_output><empty_output><jupyter_text>3. Find the vehicle that improved the mostFind the max mpg change, and then use query or indexing to see what model it is!<jupyter_code>max_mpg_change = model_mpg["mpg_change"].max()
print(max_mpg_change)
model_mpg[mod'mpg_change' == max_mpg_change]
#model_mpg.query('mpg_change == 10.6666666667')<jupyter_output>10.6666666667
{'fraction_non_alphanumeric': 0.09596662030598054, 'fraction_numerical': 0.04172461752433936, 'mean_word_length': 7.222857142857142, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '67384', 'license': 'Apache-2.0', 'n_tokens_mistral': 548, 'n_tokens_neox': 499, 'n_words': 152, 'path': 'results_merged.ipynb', 'repo_name': 'mohamedmahmed/dap_case_study_2', 'size': '1438'}