<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
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>cars1=pd.read_csv('cars1.csv')
cars2=pd.read_csv('cars2.csv')<jupyter_output>mpg  cylinders  displacement horsepower  weight  acceleration  model  \
0  18.0          8           307        130    3504          12.0     70   
1  15.0          8           350        165    3693          11.5     70   
2  18.0          8           318        150    3436          11.0     70   
3  16.0          8           304        150    3433          12.0     70   
4  17.0          8           302        140    3449          10.5     70   

   origin                        car  Unnamed: 9  Unnamed: 10  Unnamed: 11  \
0       1  chevrolet chevelle malibu         NaN          NaN          NaN   
1       1          buick skylark 320         NaN          NaN          NaN   
2       1         plymouth satellite         NaN          NaN          NaN   
3       1              amc rebel sst         NaN          NaN          NaN   
4       1                ford torino         NaN          NaN          NaN   

   Unnamed: 12  Unnamed: 13  
0          NaN          NaN  
1          NaN[...]<jupyter_text>Step 4. Oops, it seems our first dataset has some unnamed blank columns, fix cars1<jupyter_code>cars1.head()
#后几列  没有值
# 直接切出来有值的
cars1=cars1.loc[:,'mpg':'car']
cars1<jupyter_output><empty_output><jupyter_text>Step 5. What is the number of observations in each dataset?<jupyter_code># print(cars1.shape[0])
# print(cars2.shape[0])
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.shape<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>owners=np.random.randint(15000,73001,398)
owners<jupyter_output><empty_output><jupyter_text>Step 8. Add the column owners to cars<jupyter_code># cars['owners']=pd.Series(owners)
cars['owners']=owners<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08311395261376457, 'fraction_numerical': 0.07220759684091764, 'mean_word_length': 2.2048192771084336, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 3, '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': '520263', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1019, 'n_tokens_neox': 877, 'n_words': 223, 'path': '05_Merge/Auto_MPG/Exercises.ipynb', 'repo_name': 'Shen7me/pandas_exercises', 'size': '2659'}