如何对已有变量的水平条形图中的值进行排序

发布于 2025-01-16 18:35:00 字数 343 浏览 1 评论 0原文

输入图片此处描述如何根据 top10[ActiveCases] 对值进行排序?我似乎没有得到正确的语法。

top10=df[0:21]
top10
plt.barh(top10['Country,Other'],width=top10['ActiveCases'])
plt.title("Top 10 countries with highest active cases")

enter image description hereHow do I sort the values based on top10[ActiveCases]? I don't seem to get the syntax right.

top10=df[0:21]
top10
plt.barh(top10['Country,Other'],width=top10['ActiveCases'])
plt.title("Top 10 countries with highest active cases")

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

差↓一点笑了 2025-01-23 18:35:00

在创建图表之前,使用

    top10 = top20
    top10.sort_values(by='ActiveCases')
    top10.head(10).plot(kind='barh')

这将绘制 10 个最高的国家/地区

before creating the graph use

    top10 = top20
    top10.sort_values(by='ActiveCases')
    top10.head(10).plot(kind='barh')

this will plot the 10 highest countries

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文