Since 0.17.0 version you can do .round(n)

df.round(2)
      0     1     2     3
0  0.06  0.67  0.77  0.71
1  0.80  0.56  0.97  0.15
2  0.03  0.59  0.11  0.95
3  0.33  0.19  0.46  0.92

df
          0         1         2         3
0  0.057116  0.669422  0.767117  0.708115
1  0.796867  0.557761  0.965837  0.147157
2  0.029647  0.593893  0.114066  0.950810
3  0.325707  0.193619  0.457812  0.920403
Answer from piroot on Stack Overflow
🌐
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.
Discussions

python - How do you display values in a pandas dataframe column with 2 decimal places? - Stack Overflow
However, the problem is that I ... in 2 decimal places, but values like 0.5 are staying at 1 decimal place since they don't need to be rounded. Is there a function I can apply that gives the following type of output: Current After Changes 0 0.00 0.5 0.50 1.01 1.01 1.133333 1.13 · Ideally, these values will be rounded but I am open to truncating if that is all that works. ... If you want to only modify the format of your values without doing any operation in pandas, you should ... More on stackoverflow.com
🌐 stackoverflow.com
python - Display 2 decimal places, and use commas to separate thousands, in Jupyter/pandas? - Stack Overflow
I'm working with pandas 0.18 in Jupyter. I'd like to configure Jupyter/pandas to display 2 decimal places throughout, and to use comma separators in thousands. How can I do this? 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
Convert values in pandas dataframe to two decimal points - Stack Overflow
What if you want the column NO to have 2 decimals places instead of 1? Like 0.00 instead of 0.0 2020-03-20T11:56:03.723Z+00:00 ... Oh ok. Thanks for quick reply. 2020-03-20T11:59:17.057Z+00:00 ... 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. ... But if the Series has fewer decimal points than the number ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
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:
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.round.html
pandas.DataFrame.round — pandas documentation - PyData |
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.).
🌐
freeCodeCamp
freecodecamp.org › news › how-to-round-a-float-in-pandas
Pandas round() Method – How To Round a Float in Pandas
March 13, 2023 - import pandas as pd data = ... column. The column had these values: [20.5550, 21.03535, 19.67373, 18.233233]. Using the round() method, we rounded the values to 2 decimal places: df['cost'].round(2)....
🌐
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.
🌐
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.
Find elsewhere
🌐
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 ·
🌐
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...
🌐
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.).
🌐
CopyProgramming
copyprogramming.com › howto › how-do-you-display-values-in-a-pandas-dataframe-column-with-2-decimal-places
Python Pandas Round and Display Decimal 2: Complete Guide with 2026 Best Practices - Python pandas round and display decimal 2
December 4, 2025 - Each format specifier provides granular control for professional presentation. When you want all float displays in your session to consistently show 2 decimal places: import pandas as pd # Set globally for the session pd.set_option('display.precision', 2) # Alternative: set float format with formatting function pd.options.display.float_format = '{:.2f}'.format # Display without scientific notation pd.set_option('display.float_format', lambda x: f'{x:.2f}')
🌐
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....
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
🌐
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