<jupyter_start><jupyter_text>MPG CarsCheck out [Cars Exercises Video Tutorial](https://www.youtube.com/watch?v=avzLRBxoguU&list=PLgJhDSE2ZLxaY_DigHeiIDC1cD09rXgJv&index=3) to watch a data scientist go through the exercises  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
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 to a variable called cars1 and cars2<jupyter_code>cars1 = pd.read_csv("https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/05_Merge/Auto_MPG/cars1.csv")
cars2 = pd.read_csv("https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/05_Merge/Auto_MPG/cars2.csv")

print(cars1.head())
print(cars2.head())<jupyter_output>mpg  cylinders  displacement  ... Unnamed: 11  Unnamed: 12  Unnamed: 13
0  18.0          8           307  ...         NaN          NaN          NaN
1  15.0          8           350  ...         NaN          NaN          NaN
2  18.0          8           318  ...         NaN          NaN          NaN
3  16.0          8           304  ...         NaN          NaN          NaN
4  17.0          8           302  ...         NaN          NaN          NaN

[5 rows x 14 columns]
    mpg  cylinders  displacement  ... model  origin                 car
0  33.0          4            91  ...    76       3         honda civic
1  20.0          6           225  ...    76       1      dodge aspen se
2  18.0          6           250  ...    76       1   ford granada ghia
3  18.5          6           250  ...    76       1  pontiac ventura sj
4  17.5          6           258  ...    76       1       amc pacer d/l

[5 rows x 9 columns]<jupyter_text>Step 4. Oops, it seems our first dataset has some unnamed blank columns, fix cars1<jupyter_code>cars1 = cars1.loc[:, "mpg":"car"]
cars1.head()<jupyter_output><empty_output><jupyter_text>Step 5. What is the number of observations in each dataset?<jupyter_code>print(cars1.shape)
print(cars2.shape)<jupyter_output>(198, 9)
(200, 9)<jupyter_text>Step 6. Join cars1 and cars2 into a single DataFrame called cars<jupyter_code>cars = cars1.append(cars2)
cars<jupyter_output><empty_output><jupyter_text>Step 7. Oops, there is a column missing, called owners. Create a random number Series from 15,000 to 73,000.<jupyter_code>nr_owners = np.random.randint(15000, high=73001, size=398, dtype='l')
nr_owners<jupyter_output><empty_output><jupyter_text>Step 8. Add the column owners to cars<jupyter_code>cars['owners'] = nr_owners
cars.tail()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09754433833560709, 'fraction_numerical': 0.06105047748976808, 'mean_word_length': 2.5041816009557945, 'pattern_counts': {'":': 1, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 6, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '99656', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1117, 'n_tokens_neox': 997, 'n_words': 245, 'path': '05_Merge/Auto_MPG/Exercises_with_solutions.ipynb', 'repo_name': 'ekaratnida/pandas_exercises', 'size': '2932'}