xarray.Dataset.interpolate_na

Dataset.interpolate_na(dim: Hashable = None, method: str = 'linear', limit: int = None, use_coordinate: Union[bool, Hashable] = True, **kwargs) → xarray.core.dataset.Dataset

Interpolate values according to different methods.

Parameters:
  • dim (Hashable) – Specifies the dimension along which to interpolate.
  • method ({'linear', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic',) –
    ‘polynomial’, ‘barycentric’, ‘krog’, ‘pchip’,
    ’spline’}, 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’: use their respective scipy.interpolate classes.
  • use_coordinate (boolean 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.
  • limit (int, default None) – Maximum number of consecutive NaNs to fill. Must be greater than 0 or None for no limit.
  • kwargs (any) – parameters passed verbatim to the underlying interplation function
Returns:

Return type:

Dataset

See also

numpy.interp(), scipy.interpolate()