-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: misleading message when using to_datetime with format='%V %a' #50309
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: misleading message when using to_datetime with format='%V %a' #50309
Conversation
b7b5193
to
7c57883
Compare
raise ValueError("Day of the year directive '%j' is not " | ||
"compatible with ISO year directive '%G'. " | ||
"Use '%Y' instead.") |
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.
this one was never tested to begin with - have added a test to cover it
"ISO week directive '%V' must be used with the ISO year directive " | ||
"'%G' and a weekday directive '%A', '%a', '%w', or '%u'.", | ||
"ISO week directive '%V' is incompatible with the year directive " | ||
"'%Y'. Use the ISO year '%G' instead.", |
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've put the "%Y and %V used together" check before the "%V used without both %G and weekday directive", as I think it produces a more useful error message in this case
[ | ||
"ISO week directive '%V' must be used with the ISO year directive " | ||
"'%G' and a weekday directive '%A', '%a', '%w', or '%u'.", | ||
"20 Monday", | ||
"%V %A", | ||
], |
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.
on upstream/main, this one would show "ISO week directive '%V' is incompatible with the year directive '%Y'"
, which is misleading because we didn't use "%Y"
pandas/_libs/tslibs/strptime.pyx
Outdated
raise ValueError("ISO year directive '%G' must be used with " | ||
"the ISO week directive '%V' and a weekday " | ||
"directive '%A', '%a', '%w', or '%u'.") | ||
elif ("%V" in fmt and "%Y" in fmt): |
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.
elif ("%V" in fmt and "%Y" in fmt): | |
elif "%V" in fmt and "%Y" in fmt: |
Nit
Thanks @MarcoGorelli |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Good call @mroeschke to factor this out! I think it's simpler like this, and it helped find some untested code, and other code where the message was misleading
Performance is unaffected:
On this branch:
upstream/main (after having recompiled):