From c6045d63b91dd0330f690222d811e2afd6647c24 Mon Sep 17 00:00:00 2001 From: spencerkclark Date: Thu, 23 Jun 2022 06:33:22 -0400 Subject: [PATCH 1/2] Also catch OutOfBoundsTimedelta error when decoding times [test-upstream] --- doc/whats-new.rst | 4 ++++ xarray/coding/times.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 9badedbb8f2..bf6bca2127a 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -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 `_. +- 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`). + By `Spencer Clark `_. Documentation ~~~~~~~~~~~~~ diff --git a/xarray/coding/times.py b/xarray/coding/times.py index 00f565e7352..15106f11fe5 100644 --- a/xarray/coding/times.py +++ b/xarray/coding/times.py @@ -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 @@ -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 ) From 176f00b37ad40f55ba875f03d1d6beaafefdab2d Mon Sep 17 00:00:00 2001 From: spencerkclark Date: Fri, 24 Jun 2022 07:11:10 -0400 Subject: [PATCH 2/2] Add PR number to what's new entry --- doc/whats-new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index bf6bca2127a..dc9a8adf4bc 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -45,7 +45,7 @@ Bug fixes By `Michael Niklas `_. - 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`). + nanosecond-precision values (:issue:`6716`, :pull:`6717`). By `Spencer Clark `_. Documentation