Created
June 17, 2019 09:39
-
-
Save albertorb/db7dbf6bac160a2df5ce4bc1d4a643da to your computer and use it in GitHub Desktop.
Plot all categoricals within the same cell with seaborn's countplot.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import seaborn as sns | |
import pylab as plt | |
def plot_all_cat_distributions(dataframe, figsize = (20,40)): | |
""" Plot every single category frequency distribution in the same cell""" | |
max_shape = np.ceil(dataframe.shape[1] / 2) | |
fig = plt.figure(figsize=figsize) | |
for i, col in enumerate(dataframe.columns): | |
plt.subplot(max_shape, 2, i+1) | |
_ = sns.countplot(y = col, data = dataframe, order=dataframe[col].value_counts().index) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment