Performing univariate analysis using a bar chart
Like histograms, bar charts consist of rectangular bars. However, while the histogram analyzes numerical data, the bar chart analyzes categories. The x-axis typically represents the categories in our dataset while the y-axis represents the count of the categories or their occurrences by percentage. In some cases, the y-axis can also be the sum or average of a numerical column within our dataset. The bar chart provides quick insights especially when we need to quickly compare categories within our dataset.
In this recipe, we will explore how to create bar charts in seaborn
. The countplot
method in seaborn
can be used for this. seaborn
also has a barplot
method. While countplot
plots the count of each category, barplot
plots a numeric variable against each category. This makes countplot
better suited for univariate analysis, while the barplot
method is better suited for bivariate analysis.
Getting ready
We will continue to work...