With :
pd.options.display.float_format = '{:,}'.format
It displays for number x = 1234567.888 :
1,234,567.888
What is the appropriate format to show 0 decimals and add a space between thousands, millions, billions, and so on ? Like this
1 234 568
答案 0 :(得分:1)
要使用python寻找此操作,请按以下步骤操作:
from math import trunc
some_float = 1234569.02
print ('{:,}'.format(trunc(some_float)).replace(',', ' '))
您可以了解有关trunc()here的更多信息。
如@Jon Clements所指出的,您还可以使用'{:,。0f}'进行格式化。不需要导入数学库。