-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: ISO8601-compliant datetime string conversion in iterrows()
and Series construction.
#19762
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 27 commits
518ab47
156adbb
6d06cf1
f2617dd
09ae4e5
7ea24ec
fac665b
068fde2
8ceeb62
d105732
26fd14f
ab5214a
37aa8dd
7d9b27d
389a9d9
959ae62
700fa38
f8159c2
3708f4b
cb798d2
2e27f22
75268a8
8384d5e
1665922
21f7c15
5dc7a37
f9240b5
6e67070
9e6e2a7
27fdfac
6aea33d
998920c
14946f8
9e11b43
2fe7057
910f759
0b72b72
acdec06
e69f4ab
5b12cfc
a9d85ae
a5a1f57
793ea23
08d2718
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 |
---|---|---|
|
@@ -904,15 +904,19 @@ def maybe_infer_to_datetimelike(value, convert_dates=False): | |
def try_datetime(v): | ||
# safe coerce to datetime64 | ||
try: | ||
v = tslib.array_to_datetime(v, errors='raise') | ||
# GH19671 | ||
v = tslib.array_to_datetime(v, | ||
require_iso8601=True, | ||
errors='raise') | ||
except ValueError: | ||
|
||
# we might have a sequence of the same-datetimes with tz's | ||
# if so coerce to a DatetimeIndex; if they are not the same, | ||
# then these stay as object dtype | ||
try: | ||
from pandas import to_datetime | ||
return to_datetime(v) | ||
# GH19671 | ||
return to_datetime(v, require_iso8601=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. So I mean to change this with 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. changes implemented. 👍 |
||
except Exception: | ||
pass | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,6 +300,10 @@ def test_maybe_infer_to_datetimelike(self): | |
[NaT, 'b', 1]])) | ||
assert result.size == 6 | ||
|
||
# GH19671 | ||
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. ican you make a new test in pandas/tests/indexes/datetimes/test_tools.py there are a ton of tests already there, see if you can find a good place. ok to leave this on as well. 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. done 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. add a blank line before the comment 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. done |
||
result = Series(['M1701', Timestamp('20130101')]) | ||
assert result.dtype.kind == 'O' | ||
|
||
|
||
class TestConvert(object): | ||
|
||
|
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.
you dont' need to add this require_iso8601 anywhere here, except for in the actual
to_datetime()
call, where it should be True.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.
done.