<jupyter_start><jupyter_text>MPG Cars  Introduction:The following exercise utilizes data from [UC Irvine Machine Learning Repository](https://archive.ics.uci.edu/ml/datasets/Auto+MPG) Step 1. Import the necessary libraries<jupyter_code>import pandas as pd
from IPython.display import display
import numpy as np<jupyter_output><empty_output><jupyter_text>Step 2. Import the first dataset [cars1](https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/05_Merge/Auto_MPG/cars1.csv) and [cars2](https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/05_Merge/Auto_MPG/cars2.csv).       Step 3. Assign each to a variable called cars1 and cars2<jupyter_code>car1 = pd.read_csv("https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/05_Merge/Auto_MPG/cars1.csv")
car2 = pd.read_csv("https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/05_Merge/Auto_MPG/cars2.csv")
car1.head()
car2.head()<jupyter_output><empty_output><jupyter_text>Step 4. Ops it seems our first dataset has some unnamed blank columns, fix cars1<jupyter_code>car1.drop(car1.columns[car1.columns.str.startswith("Unname")], axis=1)
car1 = car1.loc[:, "mpg":"car"]<jupyter_output><empty_output><jupyter_text>Step 5. What is the number of observations in each dataset?<jupyter_code>display(car1.shape[0])
display(car2.shape[0])<jupyter_output><empty_output><jupyter_text>Step 6. Join cars1 and cars2 into a single DataFrame called cars<jupyter_code>cars = car1.append(car2)
display(cars.head())
display(cars.tail())<jupyter_output><empty_output><jupyter_text>Step 7. Ops there is a column missing, called owners. Create a random number Series from 15,000 to 73,000.<jupyter_code>owners = pd.Series(np.random.randint(15000, 73000, cars.shape[0]))<jupyter_output><empty_output><jupyter_text>Step 8. Add the column owners to cars<jupyter_code>cars["owners"] = owners
display(cars.head())<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12279792746113989, 'fraction_numerical': 0.03316062176165803, 'mean_word_length': 7.620535714285714, 'pattern_counts': {'":': 1, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '561437', 'license': 'Apache-2.0', 'n_tokens_mistral': 735, 'n_tokens_neox': 693, 'n_words': 127, 'path': 'other/pandas_exercises/05_Merge/Auto_MPG/Exercises.ipynb', 'repo_name': '619561504/jupyter-workspace', 'size': '1930'}