Skip to content

Commit bb434e5

Browse files
committed
TST: test with mixed-reso strings
1 parent afca02d commit bb434e5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/tests/tools/test_to_datetime.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,25 @@ def test_to_datetime_parse_timezone_keeps_name(self):
544544

545545

546546
class TestToDatetime:
547+
def test_to_datetime_mixed_string_resos(self):
548+
# GH#62801
549+
vals = [
550+
"2016-01-01 01:02:03",
551+
"2016-01-01 01:02:03.001",
552+
"2016-01-01 01:02:03.001002",
553+
"2016-01-01 01:02:03.001002003",
554+
]
555+
expected = DatetimeIndex([Timestamp(x).as_unit("ns") for x in vals])
556+
557+
result1 = DatetimeIndex(vals)
558+
tm.assert_index_equal(result1, expected)
559+
560+
result2 = to_datetime(vals, format="ISO8601")
561+
tm.assert_index_equal(result2, expected)
562+
563+
result3 = to_datetime(vals, format="mixed")
564+
tm.assert_index_equal(result3, expected)
565+
547566
def test_to_datetime_none(self):
548567
# GH#23055
549568
assert to_datetime(None) is NaT

0 commit comments

Comments
 (0)