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)
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
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/pandas/series/series-round.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics