Series.interpolate(method='linear', axis=0, limit=None, inplace=False, limit_direction='forward', downcast=None, **kwargs)
[source]
Interpolate values according to different methods.
Please note that only method='linear'
is supported for DataFrames/Series with a MultiIndex.
Parameters: |
method : {‘linear’, ‘time’, ‘index’, ‘values’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘barycentric’, ‘krogh’, ‘polynomial’, ‘spline’, ‘piecewise_polynomial’, ‘from_derivatives’, ‘pchip’, ‘akima’}
New in version 0.18.1: Added support for the ‘akima’ method Added interpolate method ‘from_derivatives’ which replaces ‘piecewise_polynomial’ in scipy 0.18; backwards-compatible with scipy < 0.18 axis : {0, 1}, default 0
limit : int, default None. Maximum number of consecutive NaNs to fill. limit_direction : {‘forward’, ‘backward’, ‘both’}, defaults to ‘forward’ If limit is specified, consecutive NaNs will be filled in this direction. New in version 0.17.0. inplace : bool, default False Update the NDFrame in place if possible. downcast : optional, ‘infer’ or None, defaults to None Downcast dtypes if possible. kwargs : keyword arguments to pass on to the interpolating function. |
---|---|
Returns: |
Series or DataFrame of same shape interpolated at the NaNs |
Filling in NaNs
>>> s = pd.Series([0, 1, np.nan, 3]) >>> s.interpolate() 0 0 1 1 2 2 3 3 dtype: float64
© 2011–2012 Lambda Foundry, Inc. and PyData Development Team
© 2008–2011 AQR Capital Management, LLC
© 2008–2014 the pandas development team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.19.2/generated/pandas.Series.interpolate.html