pandas.DataFrame.interpolate

DataFrame.interpolate(method='linear', axis=0, limit=None, inplace=False, downcast='infer', **kwargs)

Interpolate values according to different methods.

Parameters :

method : {‘linear’, ‘time’, ‘values’, ‘index’ ‘nearest’, ‘zero’,

‘slinear’, ‘quadratic’, ‘cubic’, ‘barycentric’, ‘krogh’, ‘polynomial’, ‘spline’ ‘piecewise_polynomial’, ‘pchip’}

axis : {0, 1}, default 0

  • 0: fill column-by-column
  • 1: fill row-by-row

limit : int, default None.

Maximum number of consecutive NaNs to fill.

inplace : bool, default False

Update the NDFrame in place if possible.

downcast : optional, ‘infer’ or None, defaults to ‘infer’

Downcast dtypes if possible.

Returns :

Series or DataFrame of same shape interpolated at the NaNs

See also

reindex, replace, fillna

Examples

# Filling in NaNs: >>> s = pd.Series([0, 1, np.nan, 3]) >>> s.interpolate() 0 0 1 1 2 2 3 3 dtype: float64