在 pandas 中格式化数字

编程入门 行业动态 更新时间:2024-10-25 01:36:46
本文介绍了在 pandas 中格式化数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

对于pandas.DataFrame:df

for a pandas.DataFrame: df

min max mean a 0.0 2.300000e+04 6.450098e+02 b 0.0 1.370000e+05 1.651754e+03 c 218.0 1.221550e+10 3.975262e+07 d 1.0 5.060000e+03 2.727708e+02 e 0.0 6.400000e+05 6.560047e+03

我想格式化显示,例如在":,.2f" 格式(即##,###.##)并删除指数.

I would like to format the display such as numbers show in the ":,.2f" format (that is ##,###.##) and remove the exponents.

我试过:df.style.format("{:,.2f}")它给出: 我不知道该怎么办.请问有线索吗?

I tried: df.style.format("{:,.2f}")which gives: <pandas.io.formats.style.Styler object at 0x108b86f60> that i have no idea what to do with. Any lead please?

推荐答案

试试这个年轻的 Pandas 学徒

try this young Pandas apprentice

pd.options.display.float_format = '{:,.2f}'.format

更多推荐

在 pandas 中格式化数字

本文发布于:2023-05-28 12:28:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/320903.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数字   pandas

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!