text_plain_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

file_path = '../input/car-price-prediction/CarPrice_Assignment.csv'
cars = pd.read_csv(file_path, index_col='car_ID')

cars.shape

cars.columns

cars.isnull().sum()

CompanyName = cars['CarName'].apply(lambda x: x.split(' ')[0])
cars.insert(2, 'CompanyName', CompanyName)
cars.drop(['CarName'], axis=1, inplace=True)

cars.CompanyName.unique()

cars.CompanyName = cars.CompanyName.str.lower()
cars.CompanyName.replace('maxda', 'mazda', inplace=True)
cars.CompanyName.replace('porcshce', 'porsche', inplace=True)
cars.CompanyName.replace('toyouta', 'toyota', inplace=True)
cars.CompanyName.replace('vokswagen', 'volkswagen', inplace=True)
cars.CompanyName.replace('vw', 'volkswagen', inplace=True)
cars.CompanyName.unique()

cars.loc[cars.duplicated()]

categorical_cols = [cname for cname in cars.columns if cars[cname].dtype == 'object' or cars[cname].nunique() < 10]
print(categorical_cols)