If you want to only modify the format of your values without doing any operation in pandas, you should just execute the following instruction:

pd.options.display.float_format = "{:,.2f}".format

This forces it not to use scientific notation (exponential notation) and always displays 2 places after the decimal point. It also adds commas.

You should be able to get more info here:

https://pandas.pydata.org/docs/user_guide/options.html#number-formatting

Examples:

0.0012             0.00
0.0123             0.01
1.2345             1.23
12.345             12.35
100                100.00
1234567890.123456  1,234,567,890.12
 
Answer from Zombraz 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 - df.drop(["LTLA Name"], axis=1).style.format("{:.2f}") 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:
Discussions

python - Converting my column to 2 decimal places - Stack Overflow
I have a dataset: df = pd.read_excel('/Users/Adeel/Desktop/ECON628-01-omerqureshi84/datasets/main-data.xlsx') It has columns with names such as "lerate" which is the log of the exchange rates for More on stackoverflow.com
🌐 stackoverflow.com
How to format float values to 2 decimal place in a dataframe except one column of the dataframe
Hi, i am trying to format the float values to 2 decimal place after replacing NA values with columns mean() and trying to keep the ID column without any decimal place, but getting error in streamlit. Can anyone help me in this. My Steps: 1. Read the dataframe df 2. created a new dataframe as ... More on discuss.streamlit.io
🌐 discuss.streamlit.io
0
0
June 19, 2020
Can't adjust dataframes decimal places
I have a dataframe with integer and float columns like so: And as you can see, some values in the Days_to_Sell column have no decimal places, while others have 4. In order to try and have some sorts of consistency, I want to use only 2 decimal places. In order to achieved that, I use the panda’s ... More on discuss.streamlit.io
🌐 discuss.streamlit.io
1
4
February 14, 2020
Round each number in a Python pandas data frame by 2 decimals - Stack Overflow
For those that come here not because ... to n decimal places, use pd.set_option instead. This methods will make all printed DataFrame on your notebook follow the option. ... from IPython.display import display with pd.option_context('precision', 3, 'float_format', '{:.2f}'.format): display(pd.DataFrame(data={'x':[1,2,3], 'y':[4,5,6]})) ... Latest pandas changes the ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.round.html
pandas.DataFrame.round — pandas 3.0.1 documentation
A DataFrame with the affected columns rounded to the specified number of decimal places. ... Round a numpy array to the given number of decimals. ... Round a Series to the given number of decimals. ... For values exactly halfway between rounded decimal values, pandas rounds to the nearest even value (e.g. -0.5 and 0.5 round to 0.0, 1.5 and 2.5 round to 2.0, etc.).
🌐
GeeksforGeeks
geeksforgeeks.org › python › formatting-integer-column-of-dataframe-in-pandas
Formatting float column of Dataframe in Pandas - GeeksforGeeks
October 3, 2025 - '{:,.2f}'.format: Formats numbers with commas and 2 decimal places. .apply(lambda x: ...): Applies the formatting to each element in the column. Large numbers can be hard to interpret.
🌐
Data to Fish
datatofish.com › round-values-pandas-dataframe
How to Round Values in a pandas DataFrame
import pandas as pd data = {'fish': ['salmon', 'pufferfish', 'shark'], 'length_m': [1.523, 0.2165, 2.1], 'width_cm': [10.2, 3.14159, 90.0] } df = pd.DataFrame(data) print(df) fish length_m width_cm 0 salmon 1.5230 10.20000 1 pufferfish 0.2165 3.14159 2 shark 2.1000 90.00000 · To round the the length_m column to two decimals places, run the following: df['length_m'] = df['length_m'].round(2) print(df['length_m']) 0 1.52 1 0.22 2 2.10 Name: length_m, dtype: float64 ·
🌐
freeCodeCamp
freecodecamp.org › news › how-to-round-a-float-in-pandas
Pandas round() Method – How To Round a Float in Pandas
March 13, 2023 - The number of decimal places to be returned is passed in as a parameter. round(2) return rounds a number to two decimal places. ... import pandas as pd data = {'cost':[20.5550, 21.03535, 19.67373, 18.233233]} df = pd.DataFrame(data) ...
Find elsewhere
🌐
Saturn Cloud
saturncloud.io › blog › how-to-set-decimal-precision-of-a-pandas-dataframe-column-with-decimal-datatype
How to Set Decimal Precision of a Pandas Dataframe Column with Decimal Datatype | Saturn Cloud Blog
January 4, 2024 - To set the decimal precision of a Pandas dataframe column with a Decimal datatype, you can use the round() method. The round() method rounds the Decimal object to the specified number of decimal places and returns a new Decimal object.
🌐
Streamlit
discuss.streamlit.io › using streamlit
How to format float values to 2 decimal place in a dataframe except one column of the dataframe - Using Streamlit - Streamlit
June 19, 2020 - Hi, i am trying to format the float values to 2 decimal place after replacing NA values with columns mean() and trying to keep the ID column without any decimal place, but getting error in streamlit. Can anyone help me in this. My Steps: 1. Read the dataframe df 2. created a new dataframe as x without the ‘ID’ column 3. Replace the NA values with it’s column mean() and stored back to x 4. Printing the dataframe x without ‘ID’ column and formated to 2 decimal place in streamlit 5. Trying to...
🌐
Medium
medium.com › @tubelwj › how-to-set-decimal-precision-and-display-formats-in-pandas-abf95de04b53
How to Set Data Decimal Precision and Display Formats in Pandas | by Gen. Devin DL. | Medium
December 14, 2025 - If we want to specify decimal precision, there are several methods: a) Using the round() method to set the number of decimal places. For example, df.round(2) will round the data in df to two decimal places.
🌐
Streamlit
discuss.streamlit.io › using streamlit
Can't adjust dataframes decimal places - Using Streamlit - Streamlit
February 14, 2020 - I have a dataframe with integer and float columns like so: And as you can see, some values in the Days_to_Sell column have no decimal places, while others have 4. In order to try and have some sorts of consistency, I want to use only 2 decimal places. In order to achieved that, I use the panda’s round function like so: st.dataframe(df_display.round(2)) But got the same result.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.io.formats.style.Styler.format.html
pandas.io.formats.style.Styler.format — pandas 3.0.1 documentation
>>> df = pd.DataFrame([[np.nan, 1.0, 'A'], [2.0, np.nan, 3.0]]) >>> df.style.format(na_rep='MISS', precision=3) 0 1 2 0 MISS 1.000 A 1 2.000 MISS 3.000 · Using a formatter specification on consistent column dtypes
🌐
IQCode
iqcode.com › code › python › pandas-format-float-decimal-places
pandas format float decimal places Code Example
February 2, 2022 - # (1) Round to specific decimal places – Single DataFrame column df['DataFrame column'].round(decimals=number of decimal places needed) # (2) Round up – Single DataFrame column df['DataFrame column'].apply(np.ceil) # (3) Round down – Single DataFrame column df['DataFrame column'].apply(np.floor) # (4) Round to specific decimals places – Entire DataFrame df.round(decimals=number of decimal places needed) ... Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond. Sign up · Develop soft skills on BrainApps Complete the IQ Test ... pandas astype float d
Top answer
1 of 2
15

It seems you need DataFrame.round:

df = df.round(2)
print (df)
      NO  Topic A  Topic B  Topic C
0    0.0     1.00     1.00     1.00
1    1.0     0.55     0.64     0.55
2    2.0     0.57     0.74     0.68
3    3.0     0.85     0.86     0.85
4    4.0     0.20     0.20     0.20
5    5.0     0.85     0.84     0.85
6    6.0     0.45     0.53     0.45
7    7.0     0.62     0.66     0.70
8    8.0     0.57     0.50     0.57
9    9.0     0.85     0.90     0.88
10  10.0     0.95     0.97     0.96
2 of 2
2

The round method only works as I think you want if the values in each column (i.e., in each pandas.Series) of the DataFrame already have more decimal points than the value you are passing to round.

For instance:

pd.Series([1.09185, 2.31476]).round(2)

returns:

0    1.09
1    2.31
dtype: float64

But if the Series has fewer decimal points than the number you are trying to round, you will not get the desired visual result. For instance:

pd.Series([1.6, 2.3]).round(2)

returns:

0    1.6
1    2.3
dtype: float64

This is mathematically correct, since the numbers in the second Series already have fewer decimal points than 2. But it is not what you visually expect.

If you only want to change the display of a Series or DataFrame inside a notebook, you should use pandas.set_option("display.precision", 2). This changes the visual representation of the Series or DataFrame, without changing the inner precision of the actual numbers.

If for some reason you need to save a Series or DataFrame with the numbers already with the desired decimal points, you can apply a function that converts the object to string type and formats the string:

pd.Series([1.6, 2.3]).apply(lambda x: f"{x:.2f}")

which returns a new Series of dtype object instead of float:

0    1.60
1    2.30
dtype: object
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.DataFrame.round.html
pandas.DataFrame.round — pandas 2.2.3 documentation
A DataFrame with the affected columns rounded to the specified number of decimal places. ... Round a numpy array to the given number of decimals. ... Round a Series to the given number of decimals. ... For values exactly halfway between rounded decimal values, pandas rounds to the nearest even value (e.g. -0.5 and 0.5 round to 0.0, 1.5 and 2.5 round to 2.0, etc.).
🌐
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 - Then we use python’s map() function to iterate and apply the formatting to all the rows in the ‘Median Sales Price’ column. ... Changing the syntax to '{:,.2f}'.format will give you numbers with two decimal places.
🌐
Finxter
blog.finxter.com › 5-best-ways-to-round-decimal-places-in-pandas-dataframe-columns
5 Best Ways to Round Decimal Places in Pandas DataFrame Columns – Be on the Right Side of Change
The apply() function applies a lambda function that rounds each element in the DataFrame to two decimal places. The lambda function is a concise way to define a custom inline function, and apply() is very powerful for column-wise operations. Pandas’ applymap() is used for element-wise operations ...
🌐
Practical Business Python
pbpython.com › styling-pandas.html
Stylin’ with Pandas - Practical Business Python
(df.groupby('name')['ext price'] ... 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....