-
-
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
CLN: enforce deprecation of frequencies deprecated for offsets #57986
CLN: enforce deprecation of frequencies deprecated for offsets #57986
Conversation
I enforced deprecation of aliases |
/preview |
Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57986/ |
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 for updating!
I've left a comment, but also, in general, this still looks very complex...if we're enforcing deprecations, then this might be a good chance to simplify the logic here?
OK with adding complexity to give a good error message if someone passes freq='M'
instead of 'ME'
, as that's probably still fairly common, but periods are far less used
The code is currently very hard to read - which is OK as a temporary phase during which we're enforcing a deprecation - but ultimately the goal should be to end up something that's cleaner than it was when we started. Is that possible here?
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 for updating! A few things
- good to have the
c_PERIOD_TO_OFFSET_FREQSTR
dict, but I don't see why it's being used here:If you've already checkedif not is_period: if name.upper() in c_OFFSET_REMOVED_FREQSTR: raise ValueError( f"\'{name}\' is no longer supported for offsets. Please " f"use \'{c_OFFSET_REMOVED_FREQSTR.get(name.upper())}\' " f"instead." ) # below we raise for lowrecase monthly and bigger frequencies if (name.upper() != name and name.lower() not in {"h", "min", "s", "ms", "us", "ns"} and name.upper() not in c_PERIOD_TO_OFFSET_FREQSTR and name.upper() in c_OFFSET_TO_PERIOD_FREQSTR): raise ValueError(INVALID_FREQ_ERR_MSG.format(name))
if not is_period
, when why do you need to check if it's inc_PERIOD_TO_OFFSET_FREQSTR
? lowrecase
typo- is this part temporary
?
elif name in {"d", "b"}: name = name.upper() elif (name.upper() not in {"B", "D"} and not name.upper().startswith("W")):
If so, could you add a comment explaining why it needs to be there, possibly linking to an open issue? Ideally we should get to the point where we can get rid of all this complexity, so let's make it clear what the road towards that endpoint is
we need the check if it isn't in for example without this check |
thanks, I corrected the typo |
Yes, it's the temporary part. I left the comment below. |
thanks for explaining - is there a way to do that part without using |
but what should we do with aliases which are the same for both: period and offsets, such as After enforcing the deprecation of |
I'd suggest either that, or to add a set which contains aliases which are valid for both |
thanks, then maybe we can leave it as it is? |
cool, I think this is on the right track I think there's a logic error somewhere, as it currently gives
but 's' should definitely be supported here, right? |
Thanks for updating, looking better - still got a comment though, else dicts' responsibilities are being mixed I like the good error messages you're giving here. Perhaps |
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 for sticking with this, we might not be far off
…//github.com/natmokval/pandas into depr-enforce-deprecation-offset-depr-freqstr
thanks! this is probably good, will do another pass over tomorrow / in the week |
thank you for helping me with this PR! |
…ation-offset-depr-freqstr
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.
looks good to me
some of the test may look redundant, but we've seen issues in the past here with unsupported aliases silently getting converted to the wrong one, and none of these tests look expensive to run, so IMO it's OK to have them
leaving open a bit in case anyone has objections
msg = f"'{freq[1:]}' is deprecated and will be removed in a " | ||
f"future version. Please use '{freq.upper()[1:]}' instead." | ||
|
||
with tm.assert_produces_warning(FutureWarning, match=msg): |
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.
Will this deprecation be enforced by 3.0 as well?
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.
I am unsure if we should enforce the deprecation of lowercase 'w' by 3.0. Because we want to deprecate the lowercase 'd', 'b', and 'c' frequencies in favor of the uppercase 'D', 'B', and 'C' in 3.0, we can keep 'w' as deprecated along with 'd', 'b', and 'c'. I think it might improve code readability.
Do you think it would be better to keep 'w' as deprecated or remove 'w' and deprecate the others?
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.
OK I see. If the plan is to also deprecate the lower case aliases in the future we can keep this as is
# GH#54939 | ||
msg = "'w' is deprecated and will be removed in a future version" | ||
|
||
with tm.assert_produces_warning(FutureWarning, match=msg): |
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.
Will this deprecation be enforced by 3.0 as well?
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 is the same as the comment above.
Thanks @natmokval |
xref #52064, #55792, #55553, #55496
Enforced deprecation of aliases
M
,Q
,Y
, etc. in favour ofME
,QE
,YE
, etc. for offsets. Now the aliases are case-sensitive.P.S. Corrected a note in v3.0.0 related to PR #57627