From 7ac9ed80fc3dec18ee1704ef0dbcd4267945e811 Mon Sep 17 00:00:00 2001 From: Keewis Date: Mon, 30 Nov 2020 01:07:09 +0100 Subject: [PATCH 1/7] add examples to interp --- xarray/core/dataset.py | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 04974c58113..912a056064c 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -2711,6 +2711,78 @@ def interp( -------- scipy.interpolate.interp1d scipy.interpolate.interpn + + Examples + -------- + >>> ds = xr.Dataset( + ... data_vars={ + ... "a": ("x", [5, 7, 4]), + ... "b": ( + ... ("x", "y"), + ... [ + ... [0.1, 4.3, 2.1, 9.8], + ... [2.4, 7.9, 0.6, np.nan], + ... [6.9, np.nan, 5.3, 8.7], + ... ], + ... ), + ... }, + ... coords={"x": [0, 1, 2], "y": [10, 12, 14, 16]}, + ... ) + >>> ds + + Dimensions: (x: 3, y: 4) + Coordinates: + * x (x) int64 0 1 2 + * y (y) int64 10 12 14 16 + Data variables: + a (x) int64 5 7 4 + b (x, y) float64 0.1 4.3 2.1 9.8 2.4 7.9 0.6 nan 6.9 nan 5.3 8.7 + + 1D interpolation with the default method (linear): + >>> ds.interp(x=[0.25, 0.75, 1.25, 1.75]) + + Dimensions: (x: 3) + Coordinates: + y (x) float64 0.25 0.5 0.75 + * x (x) float64 -0.5 0.0 0.5 + Data variables: + a (x) float64 5.5 6.0 6.5 + b (x) float64 0.675 1.25 1.825 + + 1D interpolation with a different method: + >>> ds.interp(x=[0.25, 0.75, 1.25, 1.75], method="nearest") + + Dimensions: (x: 4, y: 4) + Coordinates: + * y (y) int64 10 12 14 16 + * x (x) float64 0.25 0.75 1.25 1.75 + Data variables: + a (x) float64 5.0 7.0 7.0 4.0 + b (x, y) float64 0.1 4.3 2.1 9.8 2.4 7.9 ... 0.6 nan 6.9 nan 5.3 8.7 + + 1D extrapolation: + >>> ds.interp( + ... x=[1.5, 2.5, 3.5], method="linear", kwargs={"fill_value": "extrapolate"} + ... ) + + Dimensions: (x: 3, y: 4) + Coordinates: + * y (y) int64 10 12 14 16 + * x (x) float64 1.5 2.5 3.5 + Data variables: + a (x) float64 5.5 2.5 -0.5 + b (x, y) float64 4.65 nan 2.95 nan 9.15 ... nan 13.65 nan 12.35 nan + + 2D interpolation: + >>> ds.interp(x=[0.25, 0.75, 1.25, 1.75], y=[11, 13, 15], method="linear") + + Dimensions: (x: 4, y: 3) + Coordinates: + * x (x) float64 0.25 0.75 1.25 1.75 + * y (y) int64 11 13 15 + Data variables: + a (x) float64 5.5 6.5 6.25 4.75 + b (x, y) float64 2.938 3.463 nan 4.412 3.987 ... nan nan nan nan nan """ from . import missing @@ -5974,6 +6046,7 @@ def map_blocks( ... gb = da.groupby(groupby_type) ... clim = gb.mean(dim="time") ... return gb - clim + ... >>> time = xr.cftime_range("1990-01", "1992-01", freq="M") >>> month = xr.DataArray(time.month, coords={"time": time}, dims=["time"]) >>> np.random.seed(123) From fa3e69c7deb01093aac2482be4776c1e2f904a99 Mon Sep 17 00:00:00 2001 From: Keewis Date: Mon, 30 Nov 2020 01:19:34 +0100 Subject: [PATCH 2/7] add examples to interpolate_na --- xarray/core/dataset.py | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 912a056064c..a8205543ac3 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -4316,6 +4316,50 @@ def interpolate_na( -------- numpy.interp scipy.interpolate + + Examples + -------- + >>> ds = xr.Dataset( + ... { + ... "A": ("x", [np.nan, 2, 3, np.nan, 0]), + ... "B": ("x", [3, 4, np.nan, 1, 7]), + ... "C": ("x", [np.nan, np.nan, np.nan, 5, 0]), + ... "D": ("x", [np.nan, 3, np.nan, -1, 4]), + ... }, + ... coords={"x": [0, 1, 2, 3, 4]}, + ... ) + >>> ds + + Dimensions: (x: 5) + Coordinates: + * x (x) int64 0 1 2 3 4 + Data variables: + A (x) float64 nan 2.0 3.0 nan 0.0 + B (x) float64 3.0 4.0 nan 1.0 7.0 + C (x) float64 nan nan nan 5.0 0.0 + D (x) float64 nan 3.0 nan -1.0 4.0 + + >>> ds.interpolate_na(dim="x", method="linear") + + Dimensions: (x: 5) + Coordinates: + * x (x) int64 0 1 2 3 4 + Data variables: + A (x) float64 nan 2.0 3.0 1.5 0.0 + B (x) float64 3.0 4.0 2.5 1.0 7.0 + C (x) float64 nan nan nan 5.0 0.0 + D (x) float64 nan 3.0 1.0 -1.0 4.0 + + >>> ds.interpolate_na(dim="x", method="linear", fill_value="extrapolate") + + Dimensions: (x: 5) + Coordinates: + * x (x) int64 0 1 2 3 4 + Data variables: + A (x) float64 1.0 2.0 3.0 1.5 0.0 + B (x) float64 3.0 4.0 2.5 1.0 7.0 + C (x) float64 20.0 15.0 10.0 5.0 0.0 + D (x) float64 5.0 3.0 1.0 -1.0 4.0 """ from .missing import _apply_over_vars_with_dim, interp_na From 41d3c374ad772a287826f70f48354b9273f2cb88 Mon Sep 17 00:00:00 2001 From: Keewis Date: Mon, 30 Nov 2020 01:29:24 +0100 Subject: [PATCH 3/7] add examples to DataArray.interp --- xarray/core/dataarray.py | 67 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index b95f681bc79..03b4716f224 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -1519,12 +1519,68 @@ def interp( Examples -------- - >>> da = xr.DataArray([1, 3], [("x", np.arange(2))]) - >>> da.interp(x=0.5) - - array(2.) + da = xr.DataArray( + data=[ + [0.1, 4.3, 2.1, 9.8], + [2.4, 7.9, 0.6, np.nan], + [6.9, np.nan, 5.3, 8.7], + ], + dims=("x", "y"), + coords={"x": [0, 1, 2], "y": [10, 12, 14, 16]}, + ) + >>> da + + array([[0.1, 4.3, 2.1, 9.8], + [2.4, 7.9, 0.6, nan], + [6.9, nan, 5.3, 8.7]]) + Coordinates: + * x (x) int64 0 1 2 + * y (y) int64 10 12 14 16 + + 1D linear interpolation (the default) + >>> da.interp(x=[0.25, 0.75, 1.25, 1.75]) + + array([[0.675, 5.2 , 1.725, nan], + [1.825, 7. , 0.975, nan], + [3.525, nan, 1.775, nan], + [5.775, nan, 4.125, nan]]) + Coordinates: + * y (y) int64 10 12 14 16 + * x (x) float64 0.25 0.75 1.25 1.75 + + 1D nearest interpolation: + >>> da.interp(x=[0.25, 0.75, 1.25, 1.75], method="nearest") + + array([[0.1, 4.3, 2.1, 9.8], + [2.4, 7.9, 0.6, nan], + [2.4, 7.9, 0.6, nan], + [6.9, nan, 5.3, 8.7]]) + Coordinates: + * y (y) int64 10 12 14 16 + * x (x) float64 0.25 0.75 1.25 1.75 + + 1D linear extrapolation: + >>> da.interp( + ... x=[1.5, 2.5, 3.5], method="linear", kwargs={"fill_value": "extrapolate"} + ... ) + + array([[ 4.65, nan, 2.95, nan], + [ 9.15, nan, 7.65, nan], + [13.65, nan, 12.35, nan]]) + Coordinates: + * y (y) int64 10 12 14 16 + * x (x) float64 1.5 2.5 3.5 + + 2D linear interpolation: + >>> da.interp(x=[0.25, 0.75, 1.25, 1.75], y=[11, 13, 15], method="linear") + + array([[2.9375, 3.4625, nan], + [4.4125, 3.9875, nan], + [ nan, nan, nan], + [ nan, nan, nan]]) Coordinates: - x float64 0.5 + * x (x) float64 0.25 0.75 1.25 1.75 + * y (y) int64 11 13 15 """ if self.dtype.kind not in "uifc": raise TypeError( @@ -3496,6 +3552,7 @@ def map_blocks( ... gb = da.groupby(groupby_type) ... clim = gb.mean(dim="time") ... return gb - clim + ... >>> time = xr.cftime_range("1990-01", "1992-01", freq="M") >>> month = xr.DataArray(time.month, coords={"time": time}, dims=["time"]) >>> np.random.seed(123) From d6e16ef33629e490bb2a23663bf1b6a2662ceb3e Mon Sep 17 00:00:00 2001 From: Keewis Date: Mon, 30 Nov 2020 01:32:26 +0100 Subject: [PATCH 4/7] add examples to Dataset.interpolate_na --- xarray/core/dataarray.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index 03b4716f224..3410413d7aa 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -2367,6 +2367,25 @@ def interpolate_na( -------- numpy.interp scipy.interpolate + + Examples + -------- + >>> da = xr.DataArray( + ... [np.nan, 2, 3, np.nan, 0], dims="x", coords={"x": [0, 1, 2, 3, 4]} + ... ) + >>> da + + >>> da.interpolate_na(dim="x", method="linear") + + array([nan, 2., 3., nan, 0.]) + Coordinates: + * x (x) int64 0 1 2 3 4 + + >>> da.interpolate_na(dim="x", method="linear", fill_value="extrapolate") + + array([1. , 2. , 3. , 1.5, 0. ]) + Coordinates: + * x (x) int64 0 1 2 3 4 """ from .missing import interp_na From bc5b411d500d21b5e7c5c726b451311b2e7c7425 Mon Sep 17 00:00:00 2001 From: Keewis Date: Mon, 30 Nov 2020 02:09:24 +0100 Subject: [PATCH 5/7] fix the doctest examples --- xarray/core/dataarray.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index 3410413d7aa..a70c08b4515 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -1519,15 +1519,15 @@ def interp( Examples -------- - da = xr.DataArray( - data=[ - [0.1, 4.3, 2.1, 9.8], - [2.4, 7.9, 0.6, np.nan], - [6.9, np.nan, 5.3, 8.7], - ], - dims=("x", "y"), - coords={"x": [0, 1, 2], "y": [10, 12, 14, 16]}, - ) + >>> da = xr.DataArray( + ... data=[ + ... [0.1, 4.3, 2.1, 9.8], + ... [2.4, 7.9, 0.6, np.nan], + ... [6.9, np.nan, 5.3, 8.7], + ... ], + ... dims=("x", "y"), + ... coords={"x": [0, 1, 2], "y": [10, 12, 14, 16]}, + ... ) >>> da array([[0.1, 4.3, 2.1, 9.8], @@ -2374,6 +2374,10 @@ def interpolate_na( ... [np.nan, 2, 3, np.nan, 0], dims="x", coords={"x": [0, 1, 2, 3, 4]} ... ) >>> da + + array([nan, 2., 3., nan, 0.]) + Coordinates: + * x (x) int64 0 1 2 3 4 >>> da.interpolate_na(dim="x", method="linear") From df05e7f44eb79ffadb1f371179731071300a581a Mon Sep 17 00:00:00 2001 From: Keewis Date: Mon, 30 Nov 2020 16:17:05 +0100 Subject: [PATCH 6/7] use integers as example data --- xarray/core/dataarray.py | 65 ++++++++++++++++++++-------------------- xarray/core/dataset.py | 47 ++++++++++++++--------------- 2 files changed, 55 insertions(+), 57 deletions(-) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index a70c08b4515..faa2d3ff3a3 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -1520,66 +1520,65 @@ def interp( Examples -------- >>> da = xr.DataArray( - ... data=[ - ... [0.1, 4.3, 2.1, 9.8], - ... [2.4, 7.9, 0.6, np.nan], - ... [6.9, np.nan, 5.3, 8.7], - ... ], + ... data=[[1, 4, 2, 9], [2, 7, 6, np.nan], [6, np.nan, 5, 8]], ... dims=("x", "y"), ... coords={"x": [0, 1, 2], "y": [10, 12, 14, 16]}, ... ) >>> da - array([[0.1, 4.3, 2.1, 9.8], - [2.4, 7.9, 0.6, nan], - [6.9, nan, 5.3, 8.7]]) + array([[ 1., 4., 2., 9.], + [ 2., 7., 6., nan], + [ 6., nan, 5., 8.]]) Coordinates: * x (x) int64 0 1 2 * y (y) int64 10 12 14 16 1D linear interpolation (the default) - >>> da.interp(x=[0.25, 0.75, 1.25, 1.75]) + >>> da.interp(x=[0, 0.75, 1.25, 1.75]) - array([[0.675, 5.2 , 1.725, nan], - [1.825, 7. , 0.975, nan], - [3.525, nan, 1.775, nan], - [5.775, nan, 4.125, nan]]) + array([[1. , 4. , 2. , nan], + [1.75, 6.25, 5. , nan], + [3. , nan, 5.75, nan], + [5. , nan, 5.25, nan]]) Coordinates: * y (y) int64 10 12 14 16 - * x (x) float64 0.25 0.75 1.25 1.75 + * x (x) float64 0.0 0.75 1.25 1.75 1D nearest interpolation: - >>> da.interp(x=[0.25, 0.75, 1.25, 1.75], method="nearest") + >>> da.interp(x=[0, 0.75, 1.25, 1.75], method="nearest") - array([[0.1, 4.3, 2.1, 9.8], - [2.4, 7.9, 0.6, nan], - [2.4, 7.9, 0.6, nan], - [6.9, nan, 5.3, 8.7]]) + array([[ 1., 4., 2., 9.], + [ 2., 7., 6., nan], + [ 2., 7., 6., nan], + [ 6., nan, 5., 8.]]) Coordinates: * y (y) int64 10 12 14 16 - * x (x) float64 0.25 0.75 1.25 1.75 + * x (x) float64 0.0 0.75 1.25 1.75 1D linear extrapolation: >>> da.interp( - ... x=[1.5, 2.5, 3.5], method="linear", kwargs={"fill_value": "extrapolate"} + ... x=[1, 1.5, 2.5, 3.5], + ... method="linear", + ... kwargs={"fill_value": "extrapolate"}, ... ) - - array([[ 4.65, nan, 2.95, nan], - [ 9.15, nan, 7.65, nan], - [13.65, nan, 12.35, nan]]) + + array([[ 2. , 7. , 6. , nan], + [ 4. , nan, 5.5, nan], + [ 8. , nan, 4.5, nan], + [12. , nan, 3.5, nan]]) Coordinates: * y (y) int64 10 12 14 16 - * x (x) float64 1.5 2.5 3.5 + * x (x) float64 1.0 1.5 2.5 3.5 2D linear interpolation: - >>> da.interp(x=[0.25, 0.75, 1.25, 1.75], y=[11, 13, 15], method="linear") + >>> da.interp(x=[0, 0.75, 1.25, 1.75], y=[11, 13, 15], method="linear") - array([[2.9375, 3.4625, nan], - [4.4125, 3.9875, nan], - [ nan, nan, nan], - [ nan, nan, nan]]) + array([[2.5 , 3. , nan], + [4. , 5.625, nan], + [ nan, nan, nan], + [ nan, nan, nan]]) Coordinates: - * x (x) float64 0.25 0.75 1.25 1.75 + * x (x) float64 0.0 0.75 1.25 1.75 * y (y) int64 11 13 15 """ if self.dtype.kind not in "uifc": @@ -2381,7 +2380,7 @@ def interpolate_na( >>> da.interpolate_na(dim="x", method="linear") - array([nan, 2., 3., nan, 0.]) + array([nan, 2. , 3. , 1.5, 0. ]) Coordinates: * x (x) int64 0 1 2 3 4 diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index a8205543ac3..420377f4d29 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -2719,11 +2719,7 @@ def interp( ... "a": ("x", [5, 7, 4]), ... "b": ( ... ("x", "y"), - ... [ - ... [0.1, 4.3, 2.1, 9.8], - ... [2.4, 7.9, 0.6, np.nan], - ... [6.9, np.nan, 5.3, 8.7], - ... ], + ... [[1, 4, 2, 9], [2, 7, 6, np.nan], [6, np.nan, 5, 8]], ... ), ... }, ... coords={"x": [0, 1, 2], "y": [10, 12, 14, 16]}, @@ -2736,53 +2732,55 @@ def interp( * y (y) int64 10 12 14 16 Data variables: a (x) int64 5 7 4 - b (x, y) float64 0.1 4.3 2.1 9.8 2.4 7.9 0.6 nan 6.9 nan 5.3 8.7 + b (x, y) float64 1.0 4.0 2.0 9.0 2.0 7.0 6.0 nan 6.0 nan 5.0 8.0 1D interpolation with the default method (linear): - >>> ds.interp(x=[0.25, 0.75, 1.25, 1.75]) + >>> ds.interp(x=[0, 0.75, 1.25, 1.75]) - Dimensions: (x: 3) + Dimensions: (x: 4, y: 4) Coordinates: - y (x) float64 0.25 0.5 0.75 - * x (x) float64 -0.5 0.0 0.5 + * y (y) int64 10 12 14 16 + * x (x) float64 0.0 0.75 1.25 1.75 Data variables: - a (x) float64 5.5 6.0 6.5 - b (x) float64 0.675 1.25 1.825 + a (x) float64 5.0 6.5 6.25 4.75 + b (x, y) float64 1.0 4.0 2.0 nan 1.75 6.25 ... nan 5.0 nan 5.25 nan 1D interpolation with a different method: - >>> ds.interp(x=[0.25, 0.75, 1.25, 1.75], method="nearest") + >>> ds.interp(x=[0, 0.75, 1.25, 1.75], method="nearest") Dimensions: (x: 4, y: 4) Coordinates: * y (y) int64 10 12 14 16 - * x (x) float64 0.25 0.75 1.25 1.75 + * x (x) float64 0.0 0.75 1.25 1.75 Data variables: a (x) float64 5.0 7.0 7.0 4.0 - b (x, y) float64 0.1 4.3 2.1 9.8 2.4 7.9 ... 0.6 nan 6.9 nan 5.3 8.7 + b (x, y) float64 1.0 4.0 2.0 9.0 2.0 7.0 ... 6.0 nan 6.0 nan 5.0 8.0 1D extrapolation: >>> ds.interp( - ... x=[1.5, 2.5, 3.5], method="linear", kwargs={"fill_value": "extrapolate"} + ... x=[1, 1.5, 2.5, 3.5], + ... method="linear", + ... kwargs={"fill_value": "extrapolate"}, ... ) - Dimensions: (x: 3, y: 4) + Dimensions: (x: 4, y: 4) Coordinates: * y (y) int64 10 12 14 16 - * x (x) float64 1.5 2.5 3.5 + * x (x) float64 1.0 1.5 2.5 3.5 Data variables: - a (x) float64 5.5 2.5 -0.5 - b (x, y) float64 4.65 nan 2.95 nan 9.15 ... nan 13.65 nan 12.35 nan + a (x) float64 7.0 5.5 2.5 -0.5 + b (x, y) float64 2.0 7.0 6.0 nan 4.0 nan ... 4.5 nan 12.0 nan 3.5 nan 2D interpolation: - >>> ds.interp(x=[0.25, 0.75, 1.25, 1.75], y=[11, 13, 15], method="linear") + >>> ds.interp(x=[0, 0.75, 1.25, 1.75], y=[11, 13, 15], method="linear") Dimensions: (x: 4, y: 3) Coordinates: - * x (x) float64 0.25 0.75 1.25 1.75 + * x (x) float64 0.0 0.75 1.25 1.75 * y (y) int64 11 13 15 Data variables: - a (x) float64 5.5 6.5 6.25 4.75 - b (x, y) float64 2.938 3.463 nan 4.412 3.987 ... nan nan nan nan nan + a (x) float64 5.0 6.5 6.25 4.75 + b (x, y) float64 2.5 3.0 nan 4.0 5.625 nan nan nan nan nan nan nan """ from . import missing @@ -5910,6 +5908,7 @@ def filter_by_attrs(self, **kwargs): Examples -------- >>> # Create an example dataset: + ... >>> import numpy as np >>> import pandas as pd >>> import xarray as xr From 3f93fb3e7db2aecc682d18d531997d46a1749af5 Mon Sep 17 00:00:00 2001 From: Keewis Date: Mon, 30 Nov 2020 16:59:38 +0100 Subject: [PATCH 7/7] fix the sphinx errors --- xarray/core/dataarray.py | 6 +++++- xarray/core/dataset.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index faa2d3ff3a3..dc0759917df 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -1533,7 +1533,8 @@ def interp( * x (x) int64 0 1 2 * y (y) int64 10 12 14 16 - 1D linear interpolation (the default) + 1D linear interpolation (the default): + >>> da.interp(x=[0, 0.75, 1.25, 1.75]) array([[1. , 4. , 2. , nan], @@ -1545,6 +1546,7 @@ def interp( * x (x) float64 0.0 0.75 1.25 1.75 1D nearest interpolation: + >>> da.interp(x=[0, 0.75, 1.25, 1.75], method="nearest") array([[ 1., 4., 2., 9.], @@ -1556,6 +1558,7 @@ def interp( * x (x) float64 0.0 0.75 1.25 1.75 1D linear extrapolation: + >>> da.interp( ... x=[1, 1.5, 2.5, 3.5], ... method="linear", @@ -1571,6 +1574,7 @@ def interp( * x (x) float64 1.0 1.5 2.5 3.5 2D linear interpolation: + >>> da.interp(x=[0, 0.75, 1.25, 1.75], y=[11, 13, 15], method="linear") array([[2.5 , 3. , nan], diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 420377f4d29..b352fd3d9d7 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -2735,6 +2735,7 @@ def interp( b (x, y) float64 1.0 4.0 2.0 9.0 2.0 7.0 6.0 nan 6.0 nan 5.0 8.0 1D interpolation with the default method (linear): + >>> ds.interp(x=[0, 0.75, 1.25, 1.75]) Dimensions: (x: 4, y: 4) @@ -2746,6 +2747,7 @@ def interp( b (x, y) float64 1.0 4.0 2.0 nan 1.75 6.25 ... nan 5.0 nan 5.25 nan 1D interpolation with a different method: + >>> ds.interp(x=[0, 0.75, 1.25, 1.75], method="nearest") Dimensions: (x: 4, y: 4) @@ -2757,6 +2759,7 @@ def interp( b (x, y) float64 1.0 4.0 2.0 9.0 2.0 7.0 ... 6.0 nan 6.0 nan 5.0 8.0 1D extrapolation: + >>> ds.interp( ... x=[1, 1.5, 2.5, 3.5], ... method="linear", @@ -2772,6 +2775,7 @@ def interp( b (x, y) float64 2.0 7.0 6.0 nan 4.0 nan ... 4.5 nan 12.0 nan 3.5 nan 2D interpolation: + >>> ds.interp(x=[0, 0.75, 1.25, 1.75], y=[11, 13, 15], method="linear") Dimensions: (x: 4, y: 3)