Pandas DataFrame: interpolate() function
DataFrame-interpolate() function
The interpolate() function is used to interpolate values according to different methods.
Please note that only method='linear' is supported for DataFrame/Series with a MultiIndex.
Syntax:
DataFrame.interpolate(self, method='linear', axis=0, limit=None, inplace=False, limit_direction='forward', limit_area=None, downcast=None, **kwargs)
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
method | Interpolation technique to use. One of:
|
str Default Value: ‘linear’ |
Required |
axis | Axis to interpolate along. | {0 or ‘index’, 1 or ‘columns’, None} Default Value: None |
Required |
limit | Maximum number of consecutive NaNs to fill. Must be greater than 0. | int | Optional |
inplace | Update the data in place if possible. | bool Default Value: False |
Required |
limit_direction | If limit is specified, consecutive NaNs will be filled in this direction. | {‘forward’, ‘backward’, ‘both’} Default Value: ‘forward’ |
Required |
limit_area | If limit is specified, consecutive NaNs will be filled with this restriction.
|
{None, ‘inside’, ‘outside’} Default Value: None |
Required |
downcast | Downcast dtypes if possible. | ‘infer’ or None Default Value: None |
Optional |
**kwargs | Keyword arguments to pass on to the interpolating function | Required |
Returns: Series or DataFrame
Returns the same object type as the caller, interpolated at some or all NaN values.
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame-replace() function
Next: DataFrame - droplevel() 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