-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: renaming offsets quarterly frequencies with various fiscal year ends #55711
BUG: renaming offsets quarterly frequencies with various fiscal year ends #55711
Conversation
…ont_uppercase, fix test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks! Just got a question about something, not sure why it's necessary
pandas/_libs/tslibs/offsets.pyx
Outdated
if name.upper() != name: | ||
name = name.lower() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's necessary in order to catch frequencies like 'qe-MAr'
with mix of lower/uppercase letters. Otherwise we should add all possible combinations to _dont_uppercase
list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I see, thanks!
Before this change:
In [4]: _get_offset('Qe-mAR')
Out[4]: <QuarterEnd: startingMonth=3>
After this change:
In [2]: _get_offset('Qe-mAR')
---------------------------------------------------------------------------
ValueError: Invalid frequency: qe-mar
Would it work to simplify and just do
- if name.upper() != name:
- name = name.lower()
- if name not in _dont_uppercase:
+ if name.lower() not in _dont_uppercase:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I simplified the condition. I just wasn't sure that the frequency like ‘QE-MAR’
should also pass this check.
It looks confusing: we take an uppercase string, then lowercase it and check if the string is in the _dont_uppercase
list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, but I think we want to get rid of _dont_uppercase
completely anyway
("qe-mar", "<QuarterEnd: startingMonth=3>"), | ||
("Q-MAR", "<QuarterEnd: startingMonth=3>"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice - this is a period, so indeed the period alias should be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, sorry I missed it in PR #55553
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @natmokval !
xref #55553
'qe-dec'
,'qe-jan',
and other lowercase strings for offsets quarterly frequencies with various fiscal year ends are added to _dont_uppercase list. The reason: for period they are silently converted to'Q-DEC'
, etc.test
test_not_subperiod
is fixed.