From 4bb5175b9ac595138c5de78171d10f044d09341c Mon Sep 17 00:00:00 2001 From: Mathias Hauser Date: Tue, 23 Jan 2024 13:44:14 +0100 Subject: [PATCH] infer_freq: return 'YE' (#8629 follow-up) (#8642) * infer_freq: return 'YE' (#8629 follow-up) * fix whats new --------- Co-authored-by: Maximilian Roos <5635139+max-sixty@users.noreply.github.com> --- doc/whats-new.rst | 2 +- xarray/coding/frequencies.py | 2 +- xarray/tests/test_cftimeindex.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 3364087143b..14377792f0d 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -28,7 +28,7 @@ Breaking changes - Following pandas, :py:meth:`infer_freq` will return ``"YE"``, instead of ``"Y"`` (formerly ``"A"``). This is to be consistent with the deprecation of the latter frequency string in pandas 2.2. - This is a follow up to :pull:`8415` (:issue:`8612`, :pull:`8629`). + This is a follow up to :pull:`8415` (:issue:`8612`, :pull:`8642`). By `Mathias Hauser `_. Deprecations diff --git a/xarray/coding/frequencies.py b/xarray/coding/frequencies.py index c401fb95f1c..341627ab114 100644 --- a/xarray/coding/frequencies.py +++ b/xarray/coding/frequencies.py @@ -183,7 +183,7 @@ def _get_annual_rule(self): if len(np.unique(self.index.month)) > 1: return None - return {"cs": "YS", "ce": "Y"}.get(month_anchor_check(self.index)) + return {"cs": "YS", "ce": "YE"}.get(month_anchor_check(self.index)) def _get_quartely_rule(self): if len(self.month_deltas) > 1: diff --git a/xarray/tests/test_cftimeindex.py b/xarray/tests/test_cftimeindex.py index 062756e614b..6f0e00ef5bb 100644 --- a/xarray/tests/test_cftimeindex.py +++ b/xarray/tests/test_cftimeindex.py @@ -1353,7 +1353,7 @@ def test_infer_freq_invalid_inputs(): "freq", [ "300YS-JAN", - "Y-DEC", + "YE-DEC", "YS-JUL", "2YS-FEB", "QE-NOV",