Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Counting Categorical Data | Section
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Statistical Visualization with Seaborn

bookCounting Categorical Data

A countplot is a plot that takes a categorical list and returns columns that represent the number of list entries for each category.

12345678910111213
# Importing the `seaborn` library import seaborn as sns # Importing `matplotlib.pyplot` import matplotlib.pyplot as plt # Data list data_list = ['apple', 'milk', 'milk', 'milk', 'apple', 'milk', 'milk', 'milk', 'fish'] # Creating the countplot sns.countplot(x=data_list, palette='mako') # Showing the plot plt.show()
copy

To initialize a countplot, you need to input at least 1 parameter: x (the column in which values will be counted).

Note
Note

You may also use y instead of x to change the orientation of the plot.

As seaborn is based on matplotlib, you may use a special matplotlib.pyplot library and its function plt.show() to show the plot.

Task

Swipe to start coding

  1. Import the seaborn library with the sns alias;
  2. Import the matplotlib.pyplot library with the plt alias;
  3. Initialize the x-oriented countplot for guests_list;
  4. Show the plot.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 3
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookCounting Categorical Data

Swipe to show menu

A countplot is a plot that takes a categorical list and returns columns that represent the number of list entries for each category.

12345678910111213
# Importing the `seaborn` library import seaborn as sns # Importing `matplotlib.pyplot` import matplotlib.pyplot as plt # Data list data_list = ['apple', 'milk', 'milk', 'milk', 'apple', 'milk', 'milk', 'milk', 'fish'] # Creating the countplot sns.countplot(x=data_list, palette='mako') # Showing the plot plt.show()
copy

To initialize a countplot, you need to input at least 1 parameter: x (the column in which values will be counted).

Note
Note

You may also use y instead of x to change the orientation of the plot.

As seaborn is based on matplotlib, you may use a special matplotlib.pyplot library and its function plt.show() to show the plot.

Task

Swipe to start coding

  1. Import the seaborn library with the sns alias;
  2. Import the matplotlib.pyplot library with the plt alias;
  3. Initialize the x-oriented countplot for guests_list;
  4. Show the plot.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 3
single

single

some-alt