Skip to content

Commit 6c8db5e

Browse files
Accommodate OutOfBoundsTimedelta error when decoding times (#6717)
1 parent ec41d65 commit 6c8db5e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

doc/whats-new.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Bug fixes
4343
- :py:meth:`Dataset.where` with ``drop=True`` now behaves correctly with mixed dimensions.
4444
(:issue:`6227`, :pull:`6690`)
4545
By `Michael Niklas <https://github.com/headtr1ck>`_.
46+
- Accommodate newly raised ``OutOfBoundsTimedelta`` error in the development version of
47+
pandas when decoding times outside the range that can be represented with
48+
nanosecond-precision values (:issue:`6716`, :pull:`6717`).
49+
By `Spencer Clark <https://github.com/spencerkclark>`_.
4650

4751
Documentation
4852
~~~~~~~~~~~~~

xarray/coding/times.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import numpy as np
1010
import pandas as pd
11-
from pandas.errors import OutOfBoundsDatetime
11+
from pandas.errors import OutOfBoundsDatetime, OutOfBoundsTimedelta
1212

1313
from ..core import indexing
1414
from ..core.common import contains_cftime_datetimes, is_np_datetime_like
@@ -268,7 +268,7 @@ def decode_cf_datetime(num_dates, units, calendar=None, use_cftime=None):
268268
if use_cftime is None:
269269
try:
270270
dates = _decode_datetime_with_pandas(flat_num_dates, units, calendar)
271-
except (KeyError, OutOfBoundsDatetime, OverflowError):
271+
except (KeyError, OutOfBoundsDatetime, OutOfBoundsTimedelta, OverflowError):
272272
dates = _decode_datetime_with_cftime(
273273
flat_num_dates.astype(float), units, calendar
274274
)

0 commit comments

Comments
 (0)