Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Pandas · Module

df.round

Rounds numeric DataFrame columns to a chosen precision. Use an integer for uniform precision or a dict/Series for per-column precision.

How it works

Call round with an integer to apply one precision to every numeric column, or pass a dictionary or Series to choose precision per column. The operation returns a DataFrame; columns omitted from a mapping remain unchanged, and non-numeric columns are not rounded.

Syntax

DataFrame.round(decimals=0, *args, **kwargs)

Parameters

NameTypeDescription
decimalsint, dict, or SeriesNumber of decimal places for each column. An integer applies uniformly; a dict or Series specifies per-column precision.
**args, **kwargsoptionalAdditional keyword arguments accepted for compatibility with NumPy; they have no effect.

Returns

DataFrame with the affected columns rounded to the specified number of decimal places.

Key points

  • DataFrame.round produces a DataFrame with numeric values rounded to requested decimal places.
  • Passing one integer applies uniform precision across numeric columns.
  • A dictionary or Series enables per-column precision.
  • Dictionary-like inputs identify target columns through their keys.
  • Series inputs identify target columns through their index.
  • Unspecified columns retain their existing values.

Common mistakes

  • Halfway cases use ties-to-even rather than always rounding away from zero.
  • Misspelled or extra column names in a mapping do not raise an error; they are ignored.
  • Do not rely on extra keyword arguments to alter the rounding behavior.

Example: Round selected columns

import pandas as pd

df = pd.DataFrame({
    "price": [1.234, 5.678],
    "quantity": [2.345, 6.789],
    "label": ["a", "b"],
})

rounded = df.round({"price": 2, "quantity": 1})
print(rounded)

Rounds selected numeric columns independently while leaving the text column unchanged.

When to use it

Uniform report formatting

Prepare tabular numeric output for reports by applying one consistent decimal precision.

Column-specific precision

Round measurements, prices, or ratios with different precision requirements per column.

Non-destructive transformation

Create a presentation-ready copy while preserving the original unrounded DataFrame.

Interview questions

QHow can different columns receive different precision?

An integer applies the same number of decimal places to every numeric column. A dict maps column names to individual precisions, while a Series uses its index as the column-name mapping.

Follow-up: What happens to columns omitted from a dict? They remain unchanged, so a mapping can target only the columns requiring a different precision.

QWhat does DataFrame.round return?

The method returns a DataFrame containing the affected columns rounded to the requested precision. It does not modify the original DataFrame in place.

Follow-up: How would you preserve the original while using the result? Assign the returned DataFrame to another variable, as in rounded = df.round(2).

QWhat forms can the decimals argument take?

The decimals argument accepts an integer, dictionary, or Series. Dictionary keys must be column names; for a Series, the relevant column names must be in its index.

Follow-up: What happens if a mapping includes a name absent from the DataFrame? That entry is ignored.

  • DataFrame.abs
  • DataFrame.clip
  • DataFrame.astype

Source: pandas.DataFrame.round — pandas 3.0.1 documentation. Checked 2026-10-15.