normalize a group in countplot

Solutions on MaxInterview for normalize a group in countplot by the best coders in the world

showing results for - "normalize a group in countplot"
Joachim
09 Apr 2019
1import numpy as np
2import pandas as pd
3import seaborn as sns
4sns.set(color_codes=True)
5
6df = sns.load_dataset('titanic')
7df.head()
8
9x,y = 'class', 'survived'
10
11(df
12.groupby(x)[y]
13.value_counts(normalize=True)
14.mul(100)
15.rename('percent')
16.reset_index()
17.pipe((sns.catplot,'data'), x=x,y='percent',hue=y,kind='bar'))
18
19
20