Countplot
- 01:21
How to use the Seaborn countplot function to visualize the distribution of observations across different categories.
Downloads
No associated resources to download.
Glossary
Countplot Machine Learning PythonTranscript
We're also going to look at the Seaborn countplot function, which shows us how many observations there are in each of those categories. And in this case, how many companies are in each sector. So to demonstrate this, I have a smaller example right here with just a few observations showing height, weight, and occupation. And then down in this bottom cell, you can see that I'm calling the seaborn countplot function. So first I point Python to the seaborn package. Then I call the countplot function. And the syntax of this function is first I'm gonna pass a Y axis argument, and I'm gonna tell it I want to split on occupation. So occupation contains my unique classes, and then I'm telling it where the data is coming from. So it's coming from this data frame called example DF that I created in this cell right up here. So I'm splitting by occupation. My data is coming from example df, and then I'm going to show the results of that count plot with PLT dot show, which uses the show function from pyplot. So you can see right here that the Seaborn countplot function has split my data into four classes, and it shows me the count of the number of observations in each of those classes. This is another useful way to get to know a new data set.