In [3]:
# install
# pip install seaborn
In [9]:
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
%matplotlib inline
In [14]:
# setting sns default
sns.set()
sns.set_style('darkgrid')
In [15]:
X = np.random.random_integers(10, 100, 15)
plt.plot(X)
Out[15]:
Getting Data and Preprocessing
In [10]:
names = [
'mpg'
, 'cylinders'
, 'displacement'
, 'horsepower'
, 'weight'
, 'acceleration'
, 'model_year'
, 'origin'
, 'car_name'
]
# reading the file and assigning the header
df = pd.read_csv("http://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data", sep='\s+', names=names)
df['maker'] = df.car_name.map(lambda x: x.split()[0])
df.origin = df.origin.map({1: 'America', 2: 'Europe', 3: 'Asia'})
df=df.applymap(lambda x: np.nan if x == '?' else x).dropna()
df['horsepower'] = df.horsepower.astype(float)
df.head()
Out[10]:
In [18]:
sns.factorplot(data=df, x="model_year", y="mpg")
Out[18]:
In [19]:
sns.factorplot(data=df, x="model_year", y="mpg", col="origin")
Out[19]:
In [ ]: