html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/2688#issuecomment-458768265,https://api.github.com/repos/pydata/xarray/issues/2688,458768265,MDEyOklzc3VlQ29tbWVudDQ1ODc2ODI2NQ==,6628425,2019-01-30T00:54:01Z,2019-01-30T00:54:01Z,MEMBER,"> Probably the easiest option would be to support boolean indexers directly in CFTimeIndex.get_value (by checking for a boolean dtype). Good idea -- I'll see what I can do.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,400504690 https://github.com/pydata/xarray/issues/2688#issuecomment-458430492,https://api.github.com/repos/pydata/xarray/issues/2688,458430492,MDEyOklzc3VlQ29tbWVudDQ1ODQzMDQ5Mg==,1217238,2019-01-29T07:06:20Z,2019-01-29T07:06:20Z,MEMBER,"@spencerkclark Ugh, this part of pandas is a real mess. Probably the easiest option would be to support boolean indexers directly in `CFTimeIndex.get_value` (by checking for a boolean dtype).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,400504690 https://github.com/pydata/xarray/issues/2688#issuecomment-458101606,https://api.github.com/repos/pydata/xarray/issues/2688,458101606,MDEyOklzc3VlQ29tbWVudDQ1ODEwMTYwNg==,6628425,2019-01-28T11:50:21Z,2019-01-28T11:50:21Z,MEMBER,"The issue seems to stem from the fact that the `TypeError` produced by `index.get_value(series, [True, False, True])` is not one of the exceptions that [`pandas.Series.__getitem__` is written to handle](https://github.com/pandas-dev/pandas/blob/aa05e542bc47140123157c5854cac498c3541a8c/pandas/core/series.py#L865-L909). In the case of a DatetimeIndex, `index.get_value(series, [True, False, True])` raises an `InvalidIndexError` [in place of a `TypeError` initially raised](https://github.com/pandas-dev/pandas/blob/aa05e542bc47140123157c5854cac498c3541a8c/pandas/core/indexes/base.py#L4308-L4312): ``` In [1]: import xarray as xr; import pandas as pd; import numpy as np In [2]: times = pd.date_range('2000', periods=3) In [3]: series = pd.Series([0., np.nan, 1.], index=times) In [4]: times.get_value(series, [True, False, True]) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) ~/pandas/pandas/core/indexes/base.py in get_value(self, series, key) 4290 return self._engine.get_value(s, k, -> 4291 tz=getattr(series.dtype, 'tz', None)) 4292 except KeyError as e1: ~/pandas/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value() ~/pandas/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value() ~/pandas/pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc() TypeError: During handling of the above exception, another exception occurred: InvalidIndexError Traceback (most recent call last) in ----> 1 times.get_value(series, [True, False, True]) ~/pandas/pandas/core/indexes/datetimes.py in get_value(self, series, key) 934 935 try: --> 936 return com.maybe_box(self, Index.get_value(self, series, key), 937 series, key) 938 except KeyError: ~/pandas/pandas/core/indexes/base.py in get_value(self, series, key) 4310 if is_scalar(key): # pragma: no cover 4311 raise IndexError(key) -> 4312 raise InvalidIndexError(key) 4313 4314 def set_value(self, arr, key, value): InvalidIndexError: [True, False, True] ``` This would seem to offer a simple fix for us for `CFTimeIndex.get_value` (i.e. catch the `TypeError` and raise an `InvalidIndexError`); however, `InvalidIndexError` unfortunately [is not a public exception](https://github.com/pandas-dev/pandas/blob/master/pandas/errors/__init__.py) in pandas. Raising a `KeyError` instead happens to work, but I'm not sure if it's safe to rely on that either (because we're sort of at the whim of how it gets handled in `Series.__getitem__`). @shoyer do you think you might have a recommendation here? Does either one of those options make sense, or might there be an alternative?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,400504690