Counting 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()
To initialize a countplot, you need to input at least 1 parameter: x (the column in which values will be counted).
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.
ã¿ã¹ã¯
ã¹ã¯ã€ãããŠã³ãŒãã£ã³ã°ãéå§
- Import the
seabornlibrary with thesnsalias; - Import the
matplotlib.pyplotlibrary with thepltalias; - Initialize the x-oriented countplot for
guests_list; - Show the plot.
è§£ç
ãã¹ãŠæç¢ºã§ãããïŒ
ãã£ãŒãããã¯ããããšãããããŸãïŒ
ã»ã¯ã·ã§ã³Â 1. ç« Â 3
single
AIã«è³ªåãã
AIã«è³ªåãã
äœã§ã質åããããææ¡ããã質åã®1ã€ã詊ããŠãã£ãããå§ããŠãã ãã