在熊猫中使用枢轴表时,如何显示所有值?

发布于 2025-02-09 22:25:14 字数 389 浏览 0 评论 0原文

df_agg = pd.pivot_table(df, values= 'total_revenue', index= 'order_year',aggfunc= 'sum')

运行上述代码时,这就是我得到的。我很想获得总收入列的整个数字。

order_yeartotal_revenue
20104.95994e+08
20115.23411e+08
df_agg = pd.pivot_table(df, values= 'total_revenue', index= 'order_year',aggfunc= 'sum')

When I run the above code, this is what I get. I would love to get the entire figures for the total revenue column.

order_yeartotal_revenue
20104.95994e+08
20115.23411e+08

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

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

发布评论

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

评论(1

蒗幽 2025-02-16 22:25:14

您可以添加pandas set_option来更改查看数字的方式。

代码

df_agg = pd.pivot_table(df, values= 'total_revenue', index= 'order_year',aggfunc= 'sum')
#Used 2 as I think you have financial/currency data
pd.set_option('display.float_format', lambda x: '%.2f' % x) 
df_agg

输出

”在此处输入图像说明”

you can add pandas set_option to change the way you view the numbers.

Code

df_agg = pd.pivot_table(df, values= 'total_revenue', index= 'order_year',aggfunc= 'sum')
#Used 2 as I think you have financial/currency data
pd.set_option('display.float_format', lambda x: '%.2f' % x) 
df_agg

Output

enter image description here

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