Usage question for interpolate_na #4639
-
Hi All! Just wondering what is the difference between the argument From the documentation: http://xarray.pydata.org/en/stable/generated/xarray.DataArray.interpolate_na.html |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
consider this: In [2]: da = xr.DataArray(
...: [0, np.nan, 1, np.nan, np.nan, 2, np.nan, np.nan, np.nan, 3],
...: dims="x",
...: coords={"x": np.arange(-10, 10, 2)},
...: )
...: da
Out[2]:
<xarray.DataArray (x: 10)>
array([ 0., nan, 1., nan, nan, 2., nan, nan, nan, 3.])
Coordinates:
* x (x) int64 -10 -8 -6 -4 -2 0 2 4 6 8
In [3]: da.interpolate_na(dim="x", method="nearest", limit=2)
Out[3]:
<xarray.DataArray (x: 10)>
array([ 0., 0., 1., 1., 2., 2., 2., 2., nan, 3.])
Coordinates:
* x (x) int64 -10 -8 -6 -4 -2 0 2 4 6 8
In [4]: da.interpolate_na(dim="x", method="nearest", max_gap=7)
Out[4]:
<xarray.DataArray (x: 10)>
array([ 0., 0., 1., 1., 2., 2., nan, nan, nan, 3.])
Coordinates:
* x (x) int64 -10 -8 -6 -4 -2 0 2 4 6 8 which means that:
I agree that it's pretty difficult to figure that out reading just the parameter description. Maybe examples demonstrating that would make it easier to understand? If you're up for it, we would definitely welcome a PR adding those. |
Beta Was this translation helpful? Give feedback.
consider this: