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

https://pandas.pydata.org/pandas-docs/version/0.23.4/options.html

In pandas version 1.0 this leads to some strange formatting in some cases.

Answer from jeffhale on Stack Overflow
🌐
Mark Needham
markhneedham.com › blog › 2021 › 04 › 11 › pandas-format-dataframe-numbers-commas-decimals
Pandas - Format DataFrame numbers with commas and control decimal places | Mark Needham
April 11, 2021 - This works, but we’ve lost the LTLA Name column and the Population column isn’t formatted how we’d like. Instead of passing a single style to style.format, we can instead pass a dictionary of {"column: "style"}. So to style Population with a comma as thousands separator and PercentageVaccinated with two decimal places, we can do the following:
🌐
Krbnite
krbnite.github.io › HTML-Reports-Those-Numbers-Need-Commas
HTML Reports: Those Numbers Need Commas!
January 17, 2018 - I wish integer-valued columns automatically got commas as well. But, no. That would be too easy. As for the integer variable: pandas doesn’t necessarily care that it’s an integer, but that it’s not a pandas object. Even float(num) would not benefit from setting pandas options. [In] pd.options.display.float_format = '{:,}'.format [In] [In] num = 123456789 [In] df = pd.DataFrame({'num': [123456789.]}) [In] df [Out] num 0 123,456,789.0 [In] [In] num [Out] 123456789 [In] float(num) [Out] 123456789.0
Discussions

Adding commas to a column in a dataframe
If you're talking about a pandas dataframe, then df['column_name'] is giving you the whole column as an array, not a single value. You need to iterate over the values in the column, not try to convert the whole column array to integer value, with "%d" % df['column_name']. The Exception is giving you a good hint of what's wrong. It's probably saying "Type error: a number is required, not pandas.Dataframe" or something like that. More on reddit.com
🌐 r/learnpython
5
6
October 21, 2016
python - How do I custom format a pandas integer column to display with commas as thousands separators? - Stack Overflow
Now, you need to distinguish between ... 1,234. pandas allows you to define custom formatters on a per-column basis, which is what you're asking for here. You can (and should) store integer data as integer data, just define a custom formatter for it. As for the underlying code for How to print number with commas as thousands ... More on stackoverflow.com
🌐 stackoverflow.com
python - Can you format pandas integers for display, like `pd.options.display.float_format` for floats? - Stack Overflow
I've seen this and this on formatting ... in pandas, but I'm interested in doing the same thing for integers. ... That works on the floats in my data, but will either leave annoying trailing zeroes on integers that are cast to floats, or I'll have plain integers that don't get formatted with commas... More on stackoverflow.com
🌐 stackoverflow.com
Dataframe not using commas for floats that have no decimals
I am trying to take a data frame and display it as a table. I am using st.dataframe(). The data has a few columns that are floats, but when displaying it will automatically put commas for everything except numbers that have no decimals. For example: More on discuss.streamlit.io
🌐 discuss.streamlit.io
1
0
June 4, 2021
🌐
DataScience Made Simple
datasciencemadesimple.com › home › format integer column of dataframe in python pandas
Format integer column of Dataframe in Python pandas - DataScience Made Simple
February 5, 2023 - # round to two decimal places in python pandas pd.options.display.float_format = '{:.2f}'.format print df · # Format with commas and round off to two decimal places in pandas pd.options.display.float_format = '{:,.2f}'.format print df
🌐
Saturn Cloud
saturncloud.io › blog › how-to-format-thousand-separator-for-integers-in-a-pandas-dataframe
How to Format Thousand Separator for Integers in a Pandas DataFrame | Saturn Cloud Blog
December 6, 2023 - To format thousand separators for integers in a pandas DataFrame, we can define a function that takes a number as input and returns a string representation of the number with thousand separators. def format_int_with_commas(x): """ Formats an ...
🌐
IncludeHelp
includehelp.com › python › format-a-number-with-commas-to-separate-thousands-in-pandas.aspx
Python - Format a number with commas to separate thousands in pandas
To format a number with commas to separate thousands, you can use pd.options.display method which contains a feature called float_format which will allow us to format these numbers in such a way that they can be separated with commas. ... # Importing pandas package import pandas as pd # Creating ...
🌐
Pandas
pandas.pydata.org › docs › dev › reference › api › pandas.io.formats.style.Styler.format.html
pandas.io.formats.style.Styler.format — pandas documentation
Floating point precision to use for display purposes, if not determined by the specified formatter. ... Character used as decimal separator for floats, complex and integers. ... Character used as thousands separator for floats, complex and integers. ... Use ‘html’ to replace the characters &, <, >, ', and " in cell display string with HTML-safe sequences.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › formatting-integer-column-of-dataframe-in-pandas
Formatting float column of Dataframe in Pandas - GeeksforGeeks
January 10, 2024 - In this example below code uses pandas to create a DataFrame, 'products_dataframe,' with product names and their respective prices. It prints the initial DataFrame and then formats the 'Price' column with commas and rounds the values to two decimal places.
🌐
DataScientYst
datascientyst.com › how-to-format-numbers-with-commas-for-thousands-in-pandas
How to Format Numbers with Commas for Thousands in Pandas
April 8, 2025 - To display large numbers in a more readable format we can insert commas as thousands separators in Pandas. This is especially useful when preparing data for presentation or reports. Below is a quick solution to format numbers with commas using Pandas: (1) Display Only df.style.format('{:,}') or
🌐
Towards Data Science
towardsdatascience.com › home › latest › apply thousand separator (and other formatting) to pandas dataframe
Apply Thousand Separator (and Other Formatting) to Pandas Dataframe | Towards Data Science
January 28, 2025 - We’ll use the example shown above to illustrate how to make these format changes in a Pandas dataframe. The sample data used in this tutorial can be downloaded from [Redfin](http://redfin’s data center)’s open data center. Below is a quick overview of the sample data: ... Let’s start with the ‘Median Sales Price’ column and see how we can format it by adding the thousand comma separators and a dollar sign in the front.
Top answer
1 of 4
23

You could monkey-patch pandas.io.formats.format.IntArrayFormatter:

import contextlib
import numpy as np
import pandas as pd
import pandas.io.formats.format as pf
np.random.seed(2015)

@contextlib.contextmanager
def custom_formatting():
    orig_float_format = pd.options.display.float_format
    orig_int_format = pf.IntArrayFormatter

    pd.options.display.float_format = '{:0,.2f}'.format
    class IntArrayFormatter(pf.GenericArrayFormatter):
        def _format_strings(self):
            formatter = self.formatter or '{:,d}'.format
            fmt_values = [formatter(x) for x in self.values]
            return fmt_values
    pf.IntArrayFormatter = IntArrayFormatter
    yield
    pd.options.display.float_format = orig_float_format
    pf.IntArrayFormatter = orig_int_format


df = pd.DataFrame(np.random.randint(10000, size=(5,3)), columns=list('ABC'))
df['D'] = np.random.random(df.shape[0])*10000

with custom_formatting():
    print(df)

yields

      A     B     C        D
0 2,658 2,828 4,540 8,961.77
1 9,506 2,734 9,805 2,221.86
2 3,765 4,152 4,583 2,011.82
3 5,244 5,395 7,485 8,656.08
4 9,107 6,033 5,998 2,942.53

while outside of the with-statement:

print(df)

yields

      A     B     C            D
0  2658  2828  4540  8961.765260
1  9506  2734  9805  2221.864779
2  3765  4152  4583  2011.823701
3  5244  5395  7485  8656.075610
4  9107  6033  5998  2942.530551
2 of 4
12

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

🌐
YouTube
youtube.com › watch
Formatting numbers in Pandas DataFrames - YouTube
In this video, we'll learn how to format numbers in Pandas DataFrames. We'll show how to use thousand separators and how to control the number of decimal pla...
Published   November 10, 2022
🌐
Reddit
reddit.com › r/learnpython › pandas df: how to add thousand separators to a column?
r/learnpython on Reddit: Pandas df: How to add thousand separators to a column?
May 29, 2021 -

Two points here. I've 'pd.read_csv'ed a CSV file which has three columns.

I've used the following in order to extract the data and add headings to the columns (as currently the data is just naked)

Column 1 & 3 are text, and column 2 is a number.

How can I output the number with separators? EG 1,000,000 rather than 1000000

Also, what's the best way for formatting this dataframe to be included in an email body?

🌐
Practical Business Python
pbpython.com › styling-pandas.html
Stylin’ with Pandas - Practical Business Python
Using the format function, we can use all the power of python’s string formatting tools on the data. In this case, we use ${0:,.2f} to place a leading dollar sign, add commas and round the result to 2 decimal places.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-format-numbers-in-a-python-pandas-dataframe-as-currency-in-thousands-or-millions
How to Format Numbers in a Python Pandas DataFrame as Currency in Thousands or Millions | Saturn Cloud Blog
January 6, 2024 - In this case, we will use the format string "{:,.0f}K", which formats the value as a comma-separated integer with no decimal places, followed by the letter “K” to indicate thousands. import pandas as pd # create a sample DataFrame with numerical ...