Ciaren

Round numbers

Round numbers — roundNumbers

Round numeric columns to a number of decimals.

Use cases

  • Tidy currency to 2 decimals before export.
  • Reduce noisy precision for display.

What it does

Rounds each value in the target columns to decimals decimal places in place.

Before
itempricetax
Widget12.345671.23456
Gadget7.890120.78901
2 rows · 3 cols
Round numbers (columns=[price, tax], decimals=2)
After
itempricenewtaxnew
Widget12.351.23
Gadget7.890.79
2 rows · 3 cols

Configuration

Config keyTypeRequiredDescription
columnsstring[]YesNumeric columns to round
decimalsintNoDecimal places (default 0)

Generated Python code

df_2 = df_1.round({'amount': 2})

Tips & common mistakes

  • decimals: 0 returns floats, not integers (e.g. 3.0). Use Change typesinteger if you need whole numbers.
  • Listing a non-numeric column will error — round only numeric columns.

See also