pandas.Series.round#
- Series.round(decimals=0, *args, **kwargs)[source]#
Round each value in a Series to the given number of decimals.
- 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.
- *args, **kwargs
Additional arguments and keywords have no effect but might be accepted for compatibility with NumPy.
- Returns:
- Series
Rounded values of the Series.
See also
numpy.around
Round values of an np.array.
DataFrame.round
Round values of a DataFrame.
Series.dt.round
Round values of data to the specified freq.
Notes
For values exactly halfway between rounded decimal values, pandas rounds to the nearest even value (e.g. -0.5 and 0.5 round to 0.0, 1.5 and 2.5 round to 2.0, etc.).
Examples
>>> s = pd.Series([-0.5, 0.1, 2.5, 1.3, 2.7]) >>> s.round() 0 -0.0 1 0.0 2 2.0 3 1.0 4 3.0 dtype: float64