-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: pd.to_datetime(infer_datetime_format=True) drops timezone #42068
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
Changes from 2 commits
2b6e9f6
09a5108
1886b22
309b5d9
7198d51
f42be84
44dbf67
a031e39
8033fe7
267b971
a5136ed
0538167
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,3 +226,29 @@ def test_parse_time_string_check_instance_type_raise_exception(): | |
result = parse_time_string("2019") | ||
expected = (datetime(2019, 1, 1), "year") | ||
assert result == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"fmt,expected", | ||
[ | ||
("%Y %m %d %H:%M:%S", True), | ||
("%Y/%m/%d %H:%M:%S", True), | ||
(r"%Y\%m\%d %H:%M:%S", True), | ||
("%Y-%m-%d %H:%M:%S", True), | ||
("%Y.%m.%d %H:%M:%S", True), | ||
("%Y%m%d %H:%M:%S", True), | ||
("%Y-%m-%dT%H:%M:%S", True), | ||
("%Y-%m-%dT%H:%M:%SZ", True), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't appear like a valid strftime directive. To parse
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your comment. ex.
But as you said, the format string like "%SZ" should be "%S%z" |
||
("%Y-%m-%dT%H:%M:%S.%f", True), | ||
("%Y-%m-%dT%H:%M:%S.%fZ", True), | ||
("%Y%m%d", False), | ||
("%Y%m", False), | ||
("%Y", False), | ||
("%Y-%m-%d", True), | ||
("%Y-%m", True), | ||
], | ||
) | ||
def test_is_iso_format(fmt, expected): | ||
# see gh-41047 | ||
result = parsing.format_is_iso(fmt) | ||
assert result == expected |
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.
As mentioned in my other comment, shouldn't
%z
be checked in theiso_template
?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 agree, I will revise my PR.