Skip to content

Commit

Permalink
BUG: renaming offsets quarterly frequencies with various fiscal year …
Browse files Browse the repository at this point in the history
…ends (#55711)

* add offsets quarterly frequencies with various fiscal year ends to _dont_uppercase, fix test

* simplify the condition in _get_offset
  • Loading branch information
natmokval authored Oct 31, 2023
1 parent 2d2d67d commit 9643679
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4616,7 +4616,28 @@ _lite_rule_alias = {
"ns": "ns",
}

_dont_uppercase = {"h", "bh", "cbh", "MS", "ms", "s", "me", "qe"}
_dont_uppercase = {
"h",
"bh",
"cbh",
"MS",
"ms",
"s",
"me",
"qe",
"qe-dec",
"qe-jan",
"qe-feb",
"qe-mar",
"qe-apr",
"qe-may",
"qe-jun",
"qe-jul",
"qe-aug",
"qe-sep",
"qe-oct",
"qe-nov",
}


INVALID_FREQ_ERR_MSG = "Invalid frequency: {0}"
Expand All @@ -4635,7 +4656,7 @@ def _get_offset(name: str) -> BaseOffset:
--------
_get_offset('EOM') --> BMonthEnd(1)
"""
if name not in _dont_uppercase:
if name.lower() not in _dont_uppercase:
name = name.upper()
name = _lite_rule_alias.get(name, name)
name = _lite_rule_alias.get(name.lower(), name)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/resample/test_period_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_basic_downsample(self, simple_period_range_series):
"rule,expected_error_msg",
[
("y-dec", "<YearEnd: month=12>"),
("qe-mar", "<QuarterEnd: startingMonth=3>"),
("Q-MAR", "<QuarterEnd: startingMonth=3>"),
("M", "<MonthEnd>"),
("w-thu", "<Week: weekday=3>"),
],
Expand Down

0 comments on commit 9643679

Please sign in to comment.