• <tfoot id='AH9I6'></tfoot>

      • <bdo id='AH9I6'></bdo><ul id='AH9I6'></ul>

      1. <i id='AH9I6'><tr id='AH9I6'><dt id='AH9I6'><q id='AH9I6'><span id='AH9I6'><b id='AH9I6'><form id='AH9I6'><ins id='AH9I6'></ins><ul id='AH9I6'></ul><sub id='AH9I6'></sub></form><legend id='AH9I6'></legend><bdo id='AH9I6'><pre id='AH9I6'><center id='AH9I6'></center></pre></bdo></b><th id='AH9I6'></th></span></q></dt></tr></i><div id='AH9I6'><tfoot id='AH9I6'></tfoot><dl id='AH9I6'><fieldset id='AH9I6'></fieldset></dl></div>

        <legend id='AH9I6'><style id='AH9I6'><dir id='AH9I6'><q id='AH9I6'></q></dir></style></legend>

        <small id='AH9I6'></small><noframes id='AH9I6'>

      2. Seborn.countlot:按计数对类别进行排序

        Seaborn.countplot : order categories by count(Seborn.countlot:按计数对类别进行排序)

            <tbody id='9GwDh'></tbody>
          1. <legend id='9GwDh'><style id='9GwDh'><dir id='9GwDh'><q id='9GwDh'></q></dir></style></legend>

                <i id='9GwDh'><tr id='9GwDh'><dt id='9GwDh'><q id='9GwDh'><span id='9GwDh'><b id='9GwDh'><form id='9GwDh'><ins id='9GwDh'></ins><ul id='9GwDh'></ul><sub id='9GwDh'></sub></form><legend id='9GwDh'></legend><bdo id='9GwDh'><pre id='9GwDh'><center id='9GwDh'></center></pre></bdo></b><th id='9GwDh'></th></span></q></dt></tr></i><div id='9GwDh'><tfoot id='9GwDh'></tfoot><dl id='9GwDh'><fieldset id='9GwDh'></fieldset></dl></div>
                  <bdo id='9GwDh'></bdo><ul id='9GwDh'></ul>

                • <small id='9GwDh'></small><noframes id='9GwDh'>

                  <tfoot id='9GwDh'></tfoot>
                  本文介绍了Seborn.countlot:按计数对类别进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我知道seaborn.countplotorder属性,可以设置该属性来确定类别的顺序。但我想做的是让类别按降序排列。我知道我可以通过手动计算计数来实现这一点(在原始数据帧上使用groupby操作,等等)。但我想知道seaborn.countplot是否存在此功能。令人惊讶的是,我在任何地方都找不到这个问题的答案。

                  推荐答案

                  据我所知,seaborn.countplot中没有内置此功能-order参数仅接受类别的字符串列表,并将排序逻辑留给用户。

                  如果您有DataFrame,value_counts()就不难做到这一点。例如,

                  import pandas as pd
                  import seaborn as sns
                  import matplotlib.pyplot as plt
                  
                  sns.set(style='darkgrid')
                  
                  titanic = sns.load_dataset('titanic')
                  sns.countplot(x = 'class',
                                data = titanic,
                                order = titanic['class'].value_counts().index)
                  plt.show()
                  

                  这篇关于Seborn.countlot:按计数对类别进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Is there a way of group by month in Pandas starting at specific day number?( pandas 有从特定日期开始的按月分组的方式吗?)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)

                    <small id='aoGbM'></small><noframes id='aoGbM'>

                        <legend id='aoGbM'><style id='aoGbM'><dir id='aoGbM'><q id='aoGbM'></q></dir></style></legend>

                          <tbody id='aoGbM'></tbody>

                        <tfoot id='aoGbM'></tfoot>
                          <bdo id='aoGbM'></bdo><ul id='aoGbM'></ul>
                        • <i id='aoGbM'><tr id='aoGbM'><dt id='aoGbM'><q id='aoGbM'><span id='aoGbM'><b id='aoGbM'><form id='aoGbM'><ins id='aoGbM'></ins><ul id='aoGbM'></ul><sub id='aoGbM'></sub></form><legend id='aoGbM'></legend><bdo id='aoGbM'><pre id='aoGbM'><center id='aoGbM'></center></pre></bdo></b><th id='aoGbM'></th></span></q></dt></tr></i><div id='aoGbM'><tfoot id='aoGbM'></tfoot><dl id='aoGbM'><fieldset id='aoGbM'></fieldset></dl></div>