formatting numbers in pandas

删除回忆录丶 提交于 2019-12-10 11:54:50

问题


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

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

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?


回答1:


try this young Pandas apprentice

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


来源:https://stackoverflow.com/questions/46773603/formatting-numbers-in-pandas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!