Skip to content
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

Conversation

natmokval
Copy link
Contributor

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.

@natmokval natmokval marked this pull request as ready for review October 27, 2023 06:09
Copy link
Member

@MarcoGorelli MarcoGorelli left a 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

Comment on lines 4659 to 4660
if name.upper() != name:
name = name.lower()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary?

Copy link
Contributor Author

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.

Copy link
Member

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:

?

Copy link
Contributor Author

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.

Copy link
Member

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>"),
Copy link
Member

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

Copy link
Contributor Author

@natmokval natmokval Oct 27, 2023

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

@MarcoGorelli MarcoGorelli added the Frequency DateOffsets label Oct 27, 2023
@MarcoGorelli MarcoGorelli added this to the 2.2 milestone Oct 27, 2023
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @natmokval !

@MarcoGorelli MarcoGorelli merged commit 9643679 into pandas-dev:main Oct 31, 2023
31 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frequency DateOffsets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants