Can you format pandas integers for display, like `pd.options.display.float_format` for floats?

前端 未结 2 817
耶瑟儿~
耶瑟儿~ 2020-12-06 04:23

I\'ve seen this and this on formatting floating-point numbers for display in pandas, but I\'m interested in doing the same thing for integers

2条回答
  •  Happy的楠姐
    2020-12-06 05:02

    Another option for Jupyter notebooks is to use df.style.format('{:,}'), but it only works on a single dataframe as far as I know, so you would have to call this every time:

    table.style.format('{:,}')
              col1       col2
    0s   9,246,452  6,669,310
    >0   2,513,002  5,090,144
    
    table
           col1     col2
    0s  9246452  6669310
    >0  2513002  5090144
    

    Styling — pandas 1.1.2 documentation

提交回复
热议问题