从 DataFrame 创建直方图(其中索引值是变量)

Create histogram from DataFrame (where the index values are the variables)

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

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

如何从这个 DataFrame 中以索引作为轴值创建一个直方图?

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

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

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

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