Skip to content

Commit

Permalink
Make kind argument in CFTimeIndex._maybe_cast_slice_bound optional (
Browse files Browse the repository at this point in the history
#5359)

* [test-upstream] Make kind argument in CFTimeIndex._maybe_cast_slice_bound optional

* Update doc/whats-new.rst

Co-authored-by: keewis <keewis@users.noreply.github.com>

Co-authored-by: keewis <keewis@users.noreply.github.com>
  • Loading branch information
spencerkclark and keewis authored May 23, 2021
1 parent 35b805f commit ca72d56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/spencerkclark>`_.


Documentation
Expand Down
9 changes: 7 additions & 2 deletions xarray/coding/cftimeindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ca72d56

Please sign in to comment.