Skip to content

Accommodate OutOfBoundsTimedelta error when decoding times #6717

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

Merged
merged 2 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Bug fixes
- :py:meth:`Dataset.where` with ``drop=True`` now behaves correctly with mixed dimensions.
(:issue:`6227`, :pull:`6690`)
By `Michael Niklas <https://github.com/headtr1ck>`_.
- Accommodate newly raised ``OutOfBoundsTimedelta`` error in the development version of
pandas when decoding times outside the range that can be represented with
nanosecond-precision values (:issue:`6716`, :pull:`6717`).
By `Spencer Clark <https://github.com/spencerkclark>`_.

Documentation
~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions xarray/coding/times.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import numpy as np
import pandas as pd
from pandas.errors import OutOfBoundsDatetime
from pandas.errors import OutOfBoundsDatetime, OutOfBoundsTimedelta

from ..core import indexing
from ..core.common import contains_cftime_datetimes, is_np_datetime_like
Expand Down Expand Up @@ -268,7 +268,7 @@ def decode_cf_datetime(num_dates, units, calendar=None, use_cftime=None):
if use_cftime is None:
try:
dates = _decode_datetime_with_pandas(flat_num_dates, units, calendar)
except (KeyError, OutOfBoundsDatetime, OverflowError):
except (KeyError, OutOfBoundsDatetime, OutOfBoundsTimedelta, OverflowError):
dates = _decode_datetime_with_cftime(
flat_num_dates.astype(float), units, calendar
)
Expand Down