MCPcopy
hub / github.com/pydata/xarray / interpolate_na

Method interpolate_na

xarray/core/dataarray.py:3561–3683  ·  view source on GitHub ↗

Fill in NaNs by interpolating according to different methods. Parameters ---------- dim : Hashable or None, optional Specifies the dimension along which to interpolate. method : {"linear", "nearest", "zero", "slinear", "quadratic", "cubic", "polynomial",

(
        self,
        dim: Hashable | None = None,
        method: InterpOptions = "linear",
        limit: int | None = None,
        use_coordinate: bool | str = True,
        max_gap: (
            None
            | int
            | float
            | str
            | pd.Timedelta
            | np.timedelta64
            | datetime.timedelta
        ) = None,
        keep_attrs: bool | None = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

3559 return out
3560
3561 def interpolate_na(
3562 self,
3563 dim: Hashable | None = None,
3564 method: InterpOptions = "linear",
3565 limit: int | None = None,
3566 use_coordinate: bool | str = True,
3567 max_gap: (
3568 None
3569 | int
3570 | float
3571 | str
3572 | pd.Timedelta
3573 | np.timedelta64
3574 | datetime.timedelta
3575 ) = None,
3576 keep_attrs: bool | None = None,
3577 **kwargs: Any,
3578 ) -> Self:
3579 """Fill in NaNs by interpolating according to different methods.
3580
3581 Parameters
3582 ----------
3583 dim : Hashable or None, optional
3584 Specifies the dimension along which to interpolate.
3585 method : {"linear", "nearest", "zero", "slinear", "quadratic", "cubic", "polynomial", \
3586 "barycentric", "krogh", "pchip", "spline", "akima"}, default: "linear"
3587 String indicating which method to use for interpolation:
3588
3589 - 'linear': linear interpolation. Additional keyword
3590 arguments are passed to :py:func:`numpy.interp`
3591 - 'nearest', 'zero', 'slinear', 'quadratic', 'cubic', 'polynomial':
3592 are passed to :py:func:`scipy.interpolate.interp1d`. If
3593 ``method='polynomial'``, the ``order`` keyword argument must also be
3594 provided.
3595 - 'barycentric', 'krogh', 'pchip', 'spline', 'akima': use their
3596 respective :py:class:`scipy.interpolate` classes.
3597
3598 use_coordinate : bool or str, default: True
3599 Specifies which index to use as the x values in the interpolation
3600 formulated as `y = f(x)`. If False, values are treated as if
3601 equally-spaced along ``dim``. If True, the IndexVariable `dim` is
3602 used. If ``use_coordinate`` is a string, it specifies the name of a
3603 coordinate variable to use as the index.
3604 limit : int or None, default: None
3605 Maximum number of consecutive NaNs to fill. Must be greater than 0
3606 or None for no limit. This filling is done regardless of the size of
3607 the gap in the data. To only interpolate over gaps less than a given length,
3608 see ``max_gap``.
3609 max_gap : int, float, str, pandas.Timedelta, numpy.timedelta64, datetime.timedelta, default: None
3610 Maximum size of gap, a continuous sequence of NaNs, that will be filled.
3611 Use None for no limit. When interpolating along a datetime64 dimension
3612 and ``use_coordinate=True``, ``max_gap`` can be one of the following:
3613
3614 - a string that is valid input for pandas.to_timedelta
3615 - a :py:class:`numpy.timedelta64` object
3616 - a :py:class:`pandas.Timedelta` object
3617 - a :py:class:`datetime.timedelta` object
3618

Calls 1

interp_naFunction · 0.90