image_output_1.png
import numpy as np

import pandas as pd

import seaborn as sns

df = pd.read_csv('../input/car-price-prediction/CarPrice_Assignment.csv')

df.describe(include='all').style.background_gradient(cmap='Blues').set_properties(**{'font-family': 'Segoe UI'})

def pie_plot(df, cols_list, rows, cols):
    fig, axes = plt.subplots(rows, cols)
    for ax, col in zip(axes.ravel(), cols_list):
        df[col].value_counts().plot(ax=ax, kind='pie', figsize=(15, 15), fontsize=10, autopct='%1.0f%%')
        ax.set_title(str(col), fontsize = 12)
    plt.show()

df_c = df.copy()

df_c = df_c.drop_duplicates()

df_c = pd.get_dummies(df_c, columns=['fueltype', 'aspiration', 'carbody', 'drivewheel', 'enginelocation', 'enginetype', 'fuelsystem'])

df_c = pd.get_dummies(df_c, columns=['CarName'])

def box_plot(num_cols):
    for i in range(len(num_cols)):
        if i == 16:
            break
        else:
            l = num_cols[i]

def corr(x, y, **kwargs):
    coef = np.corrcoef(x, y)[0][1]
    label = '$\\rho$ = ' + str(round(coef, 2))
    ax = plt.gca()
    ax.annotate(label, xy=(0.3, 1), size=30, xycoords=ax.transAxes)

def scatter_features(l):
    g = sns.PairGrid(df_c, y_vars='price', x_vars=df_c[l].columns, height=5)
    g.map(plt.scatter, color='darkred', alpha=0.2)
    g.map(corr)

scatter_features(['carheight', 'curbweight', 'cylindernumber', 'enginesize', 'boreratio'])