Skip to content

Commit

Permalink
Skip freq converting in more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
aulemahal committed Feb 26, 2024
1 parent e3f0473 commit 55bd893
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xscen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 55bd893

Please sign in to comment.