I know that seaborn.countplot
has the attribute order
which can be set to determine the order of the categories. But what I would like to do is have the categories be in order of descending count. I know that I can accomplish this by computing the count manually (using a groupby
operation on the original dataframe, etc.) but I am wondering if this functionality exists with seaborn.countplot
. Surprisingly, I cannot find an answer to this question anywhere.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
This functionality is not built into
seaborn.countplot
as far as I know - theorder
parameter only accepts a list of strings for the categories, and leaves the ordering logic to the user.This is not hard to do with
value_counts()
provided you have a DataFrame though. For example,Most often, a seaborn countplot is not really necessary. Just plot with pandas bar plot: