distplot for 2 columns

Solutions on MaxInterview for distplot for 2 columns by the best coders in the world

showing results for - "distplot for 2 columns"
Grady
20 Oct 2018
1import numpy as np
2import pandas as pd
3from sklearn.datasets import load_iris
4import seaborn as sns
5
6iris = load_iris()
7iris = pd.DataFrame(data=np.c_[iris['data'], iris['target']],
8                    columns=iris['feature_names'] + ['target'])
9
10# Sort the dataframe by target
11target_0 = iris.loc[iris['target'] == 0]
12target_1 = iris.loc[iris['target'] == 1]
13target_2 = iris.loc[iris['target'] == 2]
14
15sns.distplot(target_0[['sepal length (cm)']], hist=False, rug=True)
16sns.distplot(target_1[['sepal length (cm)']], hist=False, rug=True)
17sns.distplot(target_2[['sepal length (cm)']], hist=False, rug=True)
18
19sns.plt.show()
20