【问题标题】:Create histogram from DataFrame (where the index values are the variables)从 DataFrame 创建直方图(其中索引值是变量)
【发布时间】:2021-07-20 05:58:47
【问题描述】:

我有一个包含索引及其各自值的 DataFrame。例如:

       | Count |
ID     
Amy    |   5   |
Chris  |   4   |
Gabe   |   2   |

如何从这个 DataFrame 创建一个以索引为轴值的 histplot?

我已经完成了以下操作,但它将每个条的计数设置为 1.0:

sns.histplot(data=df, y=df.index)

【问题讨论】:

    标签: python dataframe seaborn histogram


    【解决方案1】:

    直方图是用来显示连续变量分布的东西。由于您只想比较不同类别之间的计数值,因此条形图更合适。

    sns.barplot(data=df, x='Count', y=df.index)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-31
      • 2014-02-09
      • 1970-01-01
      • 2012-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多