pandas.Index.round#

Index.round(decimals=0)[source]#

Round each value in the Index to the given number of decimals.

Parameters:
decimalsint, optional

Number of decimal places to round to. If decimals is negative, it specifies the number of positions to the left of the decimal point.

Returns:
Index

A new Index with the rounded values.

Examples

>>> import pandas as pd
>>> idx = pd.Index([10.1234, 20.5678, 30.9123, 40.4567, 50.7890])
>>> idx.round(decimals=2)
Index([10.12, 20.57, 30.91, 40.46, 50.79], dtype='float64')