seaborn countplot multiple columns code example

Example 1: percentage plot of categorical variable in python woth hue

sns.barplot(x='group', y='Values', data=df, estimator=lambda x: sum(x==0)*100.0/len(x))

Example 2: seaborn boxplot multiple columns

>>> ax = sns.boxplot(x="day", y="total_bill", hue="smoker",
...                  data=tips, palette="Set3")

Example 3: countplot for different classes in a column

>>> ax = sns.countplot(x="who", data=titanic, palette="Set3")

Example 4: seaborn countplot hue stacked

df_plot = df.groupby(['class', 'survived']).size().reset_index().pivot(columns='class', index='survived', values=0)

class     First  Second  Third
survived                      
0            80      97    372
1           136      87    119

Tags:

Misc Example