Pandas DataFrame: diff() function
DataFrame - diff() function
The diff() function calculates the difference of a DataFrame element compared with another element in the DataFrame.
Syntax:DataFrame.diff(self, periods=1, axis=0)
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
periods | Periods to shift for calculating difference, accepts negative values. | int Default Value: 1 |
Required |
axis | Take difference over rows (0) or columns (1). | {0 or ‘index’, 1 or ‘columns’} Default Value: 0 |
Required |
Returns: DataFrame
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame - describe() function
Next: DataFrame - eval() 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