diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 2dc271061e4..828e8da4b44 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -33,6 +33,10 @@ Deprecations Bug fixes ~~~~~~~~~ +- Fix a minor incompatibility between partial datetime string indexing with a + :py:class:`CFTimeIndex` and upcoming pandas version 1.3.0 (:issue:`5356`, + :pull:`5359`). + By `Spencer Clark `_. Documentation diff --git a/xarray/coding/cftimeindex.py b/xarray/coding/cftimeindex.py index f0de55656fa..783fe8d04d9 100644 --- a/xarray/coding/cftimeindex.py +++ b/xarray/coding/cftimeindex.py @@ -465,9 +465,14 @@ def get_loc(self, key, method=None, tolerance=None): else: return pd.Index.get_loc(self, key, method=method, tolerance=tolerance) - def _maybe_cast_slice_bound(self, label, side, kind): + def _maybe_cast_slice_bound(self, label, side, kind=None): """Adapted from - pandas.tseries.index.DatetimeIndex._maybe_cast_slice_bound""" + pandas.tseries.index.DatetimeIndex._maybe_cast_slice_bound + + Note that we have never used the kind argument in CFTimeIndex and it is + deprecated as of pandas version 1.3.0. It exists only for compatibility + reasons. We can remove it when our minimum version of pandas is 1.3.0. + """ if not isinstance(label, str): return label