Project 1
Objective: In this project we are going to clean the dataset of '1985 Automobile Dataset'.
About the Dataset:
This is a raw dataset about cars in 1985.
Overview:
- Importing the necessary libraries and the raw data.
- Renaming the columns.
- Finding the missing values.
- Filling the missing values.
- Exporting the data into a new csv file.
- Summary and Conclusion.
1. Importing the necessary libraries and the raw data.
- In the first step, we are going to import the libraries like pandas, numpy, and matplotlib. After that we are going to import the csv file called 'auto.csv' .
- As we can see that there are 204 data points and 26 attributes in the dataset but the column names are absurdly written. Lets see all the columns at once so that we can get the idea on the number of absurdly written columns.
- By observing the above data we can find that all the column names are absurdly written. So in the next step we will be renaming the columns.
2. Renaming the Columns:
- In this step we will first pass a variable named 'column' which contains the array of the new column names and then we will pass this variable to the pandas dataframe to replace it with the new column names.
So in this way we have replaced the new column names with old one.
3. Finding the missing values:
- If we closely look at the data we will find that there are several '?' sign on the data points which indicates that there are some missing values in the dataset.
- As it is difficult to deal with '?' in tha dataset we will replacing it with 'NaN' value so that we can easily deal with the null values.
- The replancement of '?' sign to null values is successfully changed.
Now we can easily determine the columns containing the null values.
By observing the above results we have successfully counted the number missing values in different columns.
According to the results,
- Normalized Losses has 40 missing values.
- No. of Doors has 2 missing values.
- Bore has 4 missing values.
- Stroke has 4 missing values.
- Horsepower and Peak RPM have 2 missing values each.
- Price has 4 missing values.
Now lets find out the % of the missing values in all the columns.
According to the results it has been found that:
Normalized Losses is the column having the most null values of about 19.61 %.
Price,Stroke and Bore are the columns containing 1.96% null values each.
Peak RPM,Horsepower and No. of Doors are the columns containing 0.98 % null values each.
4. Filling the missing values:
- Now that we know every detail about the missing values in the dataset we will now fill the null values.
- We will replace the null values with the mean of the values of that particular column.
- The null values have been filled successfully except in 'No. of Doors' column.
- Filling the null values in 'No. of Doors' columns.
In this case the data the data is categorical so we first need to look at the data finding the unique values of it.
5. Exporting the cleaned dataframe to a csv file:
6. Summary and Conclusion:
- The raw data was imported.
- All the columns was renamed.
- The null values was counted.
- All the null values was replaced by the columns's mean value.
- In the 'No. of Doors' column the null values are replaced by the most numbered categorical indicator.
- The new dataframe is exported to a csv file.
Hence the '1985 Automobile Dataset' is cleaned.