From 55bd893d66925d2c24b7308168e6cfad4f39bdd0 Mon Sep 17 00:00:00 2001 From: Pascal Bourgault Date: Mon, 26 Feb 2024 11:15:34 -0500 Subject: [PATCH] Skip freq converting in more cases --- xscen/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xscen/utils.py b/xscen/utils.py index 6d898696..4e0adad3 100644 --- a/xscen/utils.py +++ b/xscen/utils.py @@ -1350,10 +1350,13 @@ def xrfreq_to_timedelta(freq: str): return N * pd.Timedelta(CV.xrfreq_to_timedelta(B, "NaT")) -def ensure_new_xrfreq(freq: str) -> str: +def ensure_new_xrfreq(freq: str) -> str: # noqa: C901 """Convert the frequency string to the newer syntax (pandas >= 2.2) if needed.""" # Copied from xarray xr.coding.cftime_offsets._legacy_to_new_freq # https://github.com/pydata/xarray/pull/8627/files + if not isinstance(freq, str): + # For when freq is NaN or None in a catalog + return freq try: freq_as_offset = cfoff.to_offset(freq, warn=False) except ValueError: