Pandas DataFrame: round() function
DataFrame - round() function
The round() function is used to round a DataFrame to a variable number of decimal places.
Syntax:
DataFrame.round(self, decimals=0, *args, **kwargs)
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
decimals | Number of decimal places to round each column to. If an int is given, round each column to the same number of places. Otherwise dict and Series round to variable numbers of places. Column names should be in the keys if decimals is a dict-like, or in the index if decimals is a Series. Any columns not included in decimals will be left as is. Elements of decimals which are not columns of the input will be ignored. | int, dict, Series | Required |
|
Additional keywords have no effect but might be accepted for compatibility with numpy. |
Required | |
**kwargs | Additional keywords have no effect but might be accepted for compatibility with numpy. | Optional |
Returns: DataFrame
A DataFrame with the affected columns rounded to the specified number of decimal places.
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame - rank() function
Next: DataFrame - sum() function
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework