xarray.DataArray.interpolate_na

DataArray.interpolate_na(dim=None, method='linear', limit=None, use_coordinate=True, **kwargs)

Interpolate values according to different methods.

Parameters
dimstr

Specifies the dimension along which to interpolate.

method{‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’,

‘polynomial’, ‘barycentric’, ‘krog’, ‘pchip’, ‘spline’, ‘akima’}, optional

String indicating which method to use for interpolation:

  • ‘linear’: linear interpolation (Default). Additional keyword arguments are passed to numpy.interp

  • ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘polynomial’: are passed to scipy.interpolate.interp1d. If method==’polynomial’, the order keyword argument must also be provided.

  • ‘barycentric’, ‘krog’, ‘pchip’, ‘spline’, and akima: use their respective``scipy.interpolate`` classes.

use_coordinateboolean or str, default True

Specifies which index to use as the x values in the interpolation formulated as y = f(x). If False, values are treated as if eqaully-spaced along dim. If True, the IndexVariable dim is used. If use_coordinate is a string, it specifies the name of a coordinate variariable to use as the index.

limitint, default None

Maximum number of consecutive NaNs to fill. Must be greater than 0 or None for no limit.

Returns
DataArray

See also

numpy.interp, scipy.interpolate