Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make kind argument in CFTimeIndex._maybe_cast_slice_bound optional #5359

Merged
merged 2 commits into from
May 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ 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>`_.
spencerkclark marked this conversation as resolved.
Show resolved Hide resolved


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