In [15]:
%matplotlib inline
import numpy as np
import pandas as pd
import seaborn as sns
df = (pd.read_csv('cars.csv')
.sort_values(by='hp', ascending = False)
.assign(fct_cyl=lambda x: pd.Categorical(x['cyl']))
.reset_index())
print(df.head())
In [12]:
(df.groupby('cyl')
.size())
Out[12]:
In [11]:
(df.groupby('cyl')
.hp.agg([np.mean, np.median]))
Out[11]:
In [13]:
(df.groupby('cyl')
.qsec.agg([np.mean, np.median]))
Out[13]:
In [16]:
sns.regplot(data=df, x='hp', y='qsec')
Out[16]:
In [17]:
sns.pairplot(df, hue='fct_cyl', vars=['hp', 'qsec'])
Out[17]:
In [ ]: