Make the sel error more descriptive when method is unset by jsignell · Pull Request #6774 · pydata/xarray (original) (raw)

This came up in the tutorial and I was wondering if the error could be made a little clearer. Not sure if the error message should hint that a user might want to use method.

import numpy as np import pandas as pd import xarray as xr

arr = xr.DataArray( data=np.arange(48).reshape(4, 2, 6), dims=("u", "v", "time"), coords={ "u": [-3.2, 2.1, 5.3, 6.5], "v": [-1, 2.6], "time": pd.date_range("2009-01-05", periods=6, freq="M"), }, ) arr.sel(u=5, time="2009-04-28") # I removed method="nearest"