Skip to content

Commit efa3576

Browse files
committed
enh: clarify error message the new usage of the removed year frequencies in error message
1 parent a2a5f87 commit efa3576

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

pandas/_libs/tslibs/offsets.pyx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5202,6 +5202,32 @@ deprec_to_valid_alias = {
52025202
"L": "ms",
52035203
"U": "us",
52045204
"N": "ns",
5205+
"AS": "YS",
5206+
"AS-JAN": "YS-JAN",
5207+
"AS-FEB": "YS-FEB",
5208+
"AS-MAR": "YS-MAR",
5209+
"AS-APR": "YS-APR",
5210+
"AS-MAY": "YS-MAY",
5211+
"AS-JUN": "YS-JUN",
5212+
"AS-JUL": "YS-JUL",
5213+
"AS-AUG": "YS-AUG",
5214+
"AS-SEP": "YS-SEP",
5215+
"AS-OCT": "YS-OCT",
5216+
"AS-NOV": "YS-NOV",
5217+
"AS-DEC": "YS-DEC",
5218+
"A": "Y",
5219+
"A-JAN": "Y-JAN",
5220+
"A-FEB": "Y-FEB",
5221+
"A-MAR": "Y-MAR",
5222+
"A-APR": "Y-APR",
5223+
"A-MAY": "Y-MAY",
5224+
"A-JUN": "Y-JUN",
5225+
"A-JUL": "Y-JUL",
5226+
"A-AUG": "Y-AUG",
5227+
"A-SEP": "Y-SEP",
5228+
"A-OCT": "Y-OCT",
5229+
"A-NOV": "Y-NOV",
5230+
"A-DEC": "Y-DEC",
52055231
}
52065232

52075233

pandas/tests/indexes/datetimes/test_date_range.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,22 @@ def test_date_range_depr_lowercase_frequency(self, freq, freq_depr):
814814
result = date_range("1/1/2000", periods=4, freq=freq_depr)
815815
tm.assert_index_equal(result, expected)
816816

817+
@pytest.mark.parametrize(
818+
"freq_removed,freq",
819+
[
820+
("100A", "Y"),
821+
("2A-DEC", "Y-DEC"),
822+
("100AS", "YS"),
823+
("2AS-MAY", "YS-MAY"),
824+
],
825+
)
826+
def test_error_message_for_removed_year_yearbegin_frequencies(
827+
self, freq, freq_removed
828+
):
829+
msg = f"Did you mean {freq}"
830+
with pytest.raises(ValueError, match=msg):
831+
date_range("1/1/2000", periods=2, freq=freq_removed)
832+
817833

818834
class TestDateRangeTZ:
819835
"""Tests for date_range with timezones"""

0 commit comments

Comments
 (0)