简体   繁体   中英

Remove decimals from a Float column

shocked beyond belief how difficult this is turning out to be. All I can find are suggestions to change the format of the column to 'int' but I need to keep the comma thousand separators and changing the format to int gets rid of them. THEN i can't find anything on how to add comma separators to an int column. any ideas? really is nothing for me to share in addition to above in terms of what i've tried.

Format your floats...in a string format?

my_string = '{:,.0f}'. format(my_number) 

E.g.:
x = 1000.00
'{:,.0f}'. format(x)-> 1,000

Which gives you what you want...something you can print with commas. 0f sets to 0 precision. (for how many decimal places)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM