pandas.api.extensions.ExtensionArray.round#

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

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

Only numeric dtypes can be rounded. Missing values are left as missing and the result has the same dtype as the array.

Parameters:
decimalsint, default 0

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:
ExtensionArray

Rounded values of the ExtensionArray.

See also

DataFrame.round

Round values of a DataFrame.

Series.round

Round values of a Series.

Notes

This is a non-performant default implementation. Subclasses are encouraged to override it to avoid the elementwise loop.

Examples

>>> arr = pd.array([1.234, 5.678, pd.NA], dtype="Float64")
>>> arr.round(1)
<FloatingArray>
[1.2, 5.7, <NA>]
Length: 3, dtype: Float64