Skip to content

Commit f8159c2

Browse files
committed
test datetime require iso8601 parameter
1 parent 700fa38 commit f8159c2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/indexes/datetimes/test_tools.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,22 @@ def test_datetime_bool(self, cache):
467467
NaT,
468468
to_datetime(0, cache=cache)]))
469469

470+
def test_datetime_require_iso8601(self):
471+
# GH19671
472+
s = Series(['M1809', 'M1701', Timestamp('20130101')])
473+
with pytest.raises(ValueError):
474+
to_datetime(s, require_iso8601=True, errors='raise')
475+
tm.assert_series_equal(
476+
to_datetime(s, require_iso8601=True, errors='ignore'),
477+
Series(['M1809', 'M1701', Timestamp('20130101')]))
478+
tm.assert_series_equal(
479+
to_datetime(s, require_iso8601=True, errors='coerce'),
480+
Series([NaT, NaT, Timestamp('20130101')]))
481+
tm.assert_series_equal(
482+
to_datetime(s, require_iso8601=False, errors='raise'),
483+
Series([Timestamp('18090101'), Timestamp('17010101'),
484+
Timestamp('20130101')]))
485+
470486
def test_datetime_invalid_datatype(self):
471487
# GH13176
472488

0 commit comments

Comments
 (0)