From bcc09aee12e0bb825a17cca8a1a80d437c4a0806 Mon Sep 17 00:00:00 2001 From: Mathias Hauser Date: Mon, 22 Jan 2024 19:51:46 +0100 Subject: [PATCH 1/2] infer_freq: return 'YE' (#8629 follow-up) --- xarray/coding/frequencies.py | 2 +- xarray/tests/test_cftimeindex.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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", From 2bc9925a25626ef25c2b11f599af455d8af1c1b2 Mon Sep 17 00:00:00 2001 From: Mathias Hauser Date: Mon, 22 Jan 2024 19:54:32 +0100 Subject: [PATCH 2/2] fix whats new --- 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 b810be83457..50305070ba5 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