Skip to content

LazyColumn.round

round

round(decimals: int = 0) -> LazyColumn

Rounds the numeric values in this column to the specified number of decimal places.

Parameters:

Name Type Description Default
decimals int

Number of decimal places to round to. Defaults to 0.

0

Returns:

Name Type Description
LazyColumn LazyColumn

A new LazyColumn with rounded values.

Examples:

print(df.head())
#    col1  my_column_to_test
# 0    1               1.2345
# 1    2               2.6599
# 2    3               3.1000
# 3    4               4.9999
# 4    5               5.0500

# Rounding to 2 decimal places
df["my_column_to_test"].round(2)
# Expected output (LazyColumn in lazy mode):
# [1.23, 2.66, 3.1, 5.0, 5.05]

# Rounding without specifying decimals (default=0)
df["my_column_to_test"].round()
# [1.0, 3.0, 3.0, 5.0, 5.0]