How to make a "countplot" in seaborn, plotly and matplotlib
I find myself often needing to make a 'countplot'...
How to make a countplot
I find myself often needing to make a 'countplot'. I.e. a histogram of the counts of values of a particular field. Here's how to do it using different libraries. Sometimes you want quick, sometimes pretty, sometimes interactive.
Assume you dataframe is stored in
df. And the column you are interested in is
Combine with retina jupyter matplotlib settings for prettier output.
import seaborn as sns sns.countplot(x='result', data=df)
In plotly express
import plotly.express as px px.histogram(df, x="result")
If the graphs don't show, and you're using jupyter lab. Try:
jupyter labextension install email@example.com
I prefer to use seaborn for prettiest quick output.