I have a large dataframe which has a column called Lead Rev. This column is a field of numbers such as (100000 or 5000 etc.) I want to know how to format these numbers to show commas as thousand separators. The dataset has over 200,000 rows.
Is it something like: '{:,}'.format('Lead Rev')
which gives this error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
in ()
----> 1 '{:,}'.format('Lead Rev')
ValueError: Cannot specify ',' or '_' with 's'.
解决方案
To make all your floats show comma separators by default in pandas versions 0.23 through 0.25 set the following:
pd.options.display.float_format = '{:,}'.format
In pandas version 1.0 this leads to some strange formatting in some cases.