<jupyter_start><jupyter_text>Introduction  NotebookA notebook created by FuLong for Weekly2 class practice ObjectivesAfter completing this lab you will be able to:- Identify and handle missing values- Data Formatting- Data Normalization (centering/scaling)- Data Binning- Turning categorical values to numeric variables Data AcquisitionThere are various formats for a dataset, .csv, .json, .xlsx  etc. The dataset can be stored in different places, on your local machine or sometimes online.In this section, you will learn how to load a dataset into our Jupyter Notebook.In our case, the Automobile Dataset is an online source, and it is in CSV (comma separated value) format. Let's use this dataset as an example to practice data reading.    data source: https://archive.ics.uci.edu/ml/machine-learning-databases/autos/imports-85.data    data type: csvThe Pandas Library is a useful tool that enables us to read various datasets into a data frame; our Jupyter notebook platforms have a built-in Pandas Library so that all we need to do is import Pandas without installing.<jupyter_code># import pandas library
import pandas as pd
import numpy as np<jupyter_output><empty_output><jupyter_text>Read DataWe use pandas.read_csv() function to read the csv file. In the bracket, we put the file path along with a quotation mark, so that pandas will read the file into a data frame from that address. The file path can be either an URL or your local file address.Because the data does not include headers, we can add an argument headers = None  inside the  read_csv() method, so that pandas will not automatically set the first row as a header.You can also assign the dataset to any variable you create. This dataset was hosted on IBM Cloud object click HERE for free storage.<jupyter_code># Import pandas library
import pandas as pd

# Read the online file by the URL provides above, and assign it to variable "df"
other_path = "https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DA0101EN-SkillsNetwork/labs/Data%20files/auto.csv"
df = pd.read_csv(other_path, header=None)<jupyter_output><empty_output><jupyter_text>After reading the dataset, we can use the dataframe.head(n) method to check the top n rows of the dataframe; where n is an integer. Contrary to dataframe.head(n), dataframe.tail(n) will show you the bottom n rows of the dataframe.<jupyter_code># show the first 5 rows using dataframe.head() method
print("The first 5 rows of the dataframe") 
df.head(5)
pd.DataFrame?
df=pd.DataFrame([[1],[2],[3],[4],[5],[6],[7],[8],[9]], columns = ['price'])
bins = np.linspace(min(df["price"]), max(df["price"]), 4)
print(bins)
group_names = ["low", "middle","high"]
df["prices-binnded"] = pd.cut(df["price"], bins, labels = group_names, include_lowest=True)
df
df.dtypes()
df=pd.DataFrame([[1,1000],[2,2000],[3,1000],[4,2000],[5,1000],[6,2000],[7,1000],[8,2000],[9,1000]], columns = ['age','price'])
df
df.dtypes()
df['price'] = df['price'].astype('float')
df['price'] = df['price']/df['price'].max()
df['age'] = df['age']/df['age'].max()
df
test = 'test'
aa = 'aa'
df=pd.DataFrame([[1,test],[2,aa],[3,test],[4,aa],[5,test],[6,aa],[7,test],[8,aa],[9,aa]], columns = ['age','price'])
print(pd.get_dummies(df['price']))
df.merge(pd.get_dummies(df['price']), left_index=True, right_index=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12503721345638583, 'fraction_numerical': 0.022923489133670736, 'mean_word_length': 5.801619433198381, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '255740', 'license': 'MIT', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1013, 'n_words': 387, 'path': 'Data Analysis with Python/Weekly2-ClassTest-Notebook.ipynb', 'repo_name': 'menlanshu/PythonDataScienceLearn', 'size': '3359'}