You can use round:

df.lerate = df.lerate.round(2)

Example:

>>> df = pd.DataFrame(np.random.random([3, 3]), 
                      columns=['A', 'B', 'C'], index=['first', 'second', 'third'])
>>> df.A = df.A.round(2)
>>> df
           A         B         C
first   0.82  0.581855  0.548373
second  0.21  0.536690  0.986906
third   0.78  0.100343  0.576521
Answer from mechanical_meat on Stack Overflow
🌐
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) ...
Discussions

python - How do you display values in a pandas dataframe column with 2 decimal places? - Stack Overflow
This causes it to use scientific ... keeps 2 decimal places. It makes the decision about whether to use scientific notation or not on a per-column basis, so if 1 value requires scientific notation, the whole column is displayed that way. ... unlike other answers, this permanently changes the data in your df as opposed to just the display of said data. 2023-05-18T01:11:01.583Z+00:00 ... You have to set the precision for pandas ... 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.S... More on stackoverflow.com
🌐 stackoverflow.com
Round each number in a Python pandas data frame by 2 decimals - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
🌐
GeeksforGeeks
geeksforgeeks.org › python › pandas-dataframe-round
Pandas DataFrame round() Method | Round Values to Decimal - GeeksforGeeks
Explanation: df.round(2) rounds all numeric values in the DataFrame to 2 decimal places. df.round(decimals=0) Parameters: decimals - Integer: rounds all columns to the same decimal places · Dictionary/Series: rounds specific columns to different ...
Published   January 13, 2026
🌐
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.
🌐
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...
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
Find elsewhere
🌐
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.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.round.html
pandas.DataFrame.round — pandas 3.0.2 documentation
By providing an integer each column is rounded to the same number of decimal places · >>> df.round(1) dogs cats 0 0.2 0.3 1 0.0 0.7 2 0.7 0.0 3 0.2 0.2 · With a dict, the number of places for specific columns can be specified with the column names as key and the number of decimal places as value
🌐
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.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-round-numbers-with-pandas
How to Round Numbers with Pandas | Saturn Cloud Blog
January 2, 2024 - In this example, we create a pandas DataFrame with some numerical data in a column called a. We then use the round() function to round the numbers in that column to 2 decimal places.
🌐
DataScience Made Simple
datasciencemadesimple.com › home › round off the values in column of pandas python
Round off the values in column of pandas python - DataScience Made Simple
November 15, 2019 - import pandas as pd import numpy ...mester3'], 'Score':[62.73,47.76,55.61,74.67,31.55,77.31,85.47]} df1 = pd.DataFrame(df1,columns=['Subject','Score']) print(df1) ......
🌐
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 ...
🌐
Statology
statology.org › home › how to round a single column in pandas dataframe
How to Round a Single Column in Pandas DataFrame
November 28, 2022 - #round values in 'time' column to two decimal places df.time = df.time.round(2) #view updated DataFrame print(df) athlete time points 0 A 12.44 5 1 B 15.80 7 2 C 16.01 7 3 D 5.06 9 4 E 11.08 12 5 F 12.95 9 · Each value in the time column has been rounded to two decimal places. ... Also note that the values in the other numeric column, points, have remained unchanged. The following tutorials explain how to perform other common operations in pandas:
🌐
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.
🌐
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.).
🌐
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: