w3resource

Pandas Series: round() function

Round each value in Pandas Series

The round() function is used to round each value in a Series to the given number of decimals.

Syntax:

Series.round(self, decimals=0, *args, **kwargs)
Pandas Series round() function

Parameters:

Name Description Type/Default Value Required / Optional
decimals  Number of decimal places to round to (default: 0). If decimals is negative, it specifies the number of positions to the left of the decimal point.
int Required

Returns: Series
Rounded values of the Series.

Example:

Python-Pandas Code:

import numpy as np
import pandas as pd
s = pd.Series([1.2, 2.2, 2.5])
s.round()

Output:

0    1.0
1    2.0
2    2.0
dtype: float64

Previous: Combine Series values in Pandas
Next: Product of the values for the requested Pandas axis



Follow us on Facebook and Twitter for latest update.