按组的绘图平均值,每个栏中指定数量的实例
我正在使用以下代码来绘制条形图:
df.groupby(['Borrow_Rank'])['Outcome'].mean().plot(kind = 'bar')
这显示了从0-1范围内的结果变量的平均值。但是,我需要条形图还可以显示每个组中有多少个实例或行(每个组中的2000-5000)。
I am using the following code to plot a bar chart:
df.groupby(['Borrow_Rank'])['Outcome'].mean().plot(kind = 'bar')
This is showing the mean of the Outcome variable that ranges from 0-1. However, I need the bar chart to also show how many instances or rows are in each group (2000-5000 in each group).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要显示的数据尚不清楚,但是您可以使用多个聚合功能:
output:
其他选项,将计数注释为文本:
输出:
How you want the data displayed is unclear, but you could use several aggregation functions:
output:
Other option, annotate the counts as text:
output:
reproducible dummy input: