@@ -183,7 +183,7 @@ def test_to_datetime_format_YYYYMMDD_ignore_with_outofbounds(self, cache):
183183 errors = "ignore" ,
184184 cache = cache ,
185185 )
186- expected = Index (["15010101" , "20150101" , np .nan ])
186+ expected = Index (["15010101" , "20150101" , np .nan ], dtype = object )
187187 tm .assert_index_equal (result , expected )
188188
189189 def test_to_datetime_format_YYYYMMDD_coercion (self , cache ):
@@ -1206,7 +1206,9 @@ def test_out_of_bounds_errors_ignore2(self):
12061206 # GH#12424
12071207 msg = "errors='ignore' is deprecated"
12081208 with tm .assert_produces_warning (FutureWarning , match = msg ):
1209- res = to_datetime (Series (["2362-01-01" , np .nan ]), errors = "ignore" )
1209+ res = to_datetime (
1210+ Series (["2362-01-01" , np .nan ], dtype = object ), errors = "ignore"
1211+ )
12101212 exp = Series (["2362-01-01" , np .nan ], dtype = object )
12111213 tm .assert_series_equal (res , exp )
12121214
@@ -1489,7 +1491,7 @@ def test_datetime_invalid_index(self, values, format):
14891491 warn , match = "Could not infer format" , raise_on_extra_warnings = False
14901492 ):
14911493 res = to_datetime (values , errors = "ignore" , format = format )
1492- tm .assert_index_equal (res , Index (values ))
1494+ tm .assert_index_equal (res , Index (values , dtype = object ))
14931495
14941496 with tm .assert_produces_warning (
14951497 warn , match = "Could not infer format" , raise_on_extra_warnings = False
@@ -1667,7 +1669,7 @@ def test_to_datetime_coerce_oob(self, string_arg, format, outofbounds):
16671669 "errors, expected" ,
16681670 [
16691671 ("coerce" , Index ([NaT , NaT ])),
1670- ("ignore" , Index (["200622-12-31" , "111111-24-11" ])),
1672+ ("ignore" , Index (["200622-12-31" , "111111-24-11" ], dtype = object )),
16711673 ],
16721674 )
16731675 def test_to_datetime_malformed_no_raise (self , errors , expected ):
@@ -2681,7 +2683,7 @@ def test_string_na_nat_conversion_malformed(self, cache):
26812683
26822684 result = to_datetime (malformed , errors = "ignore" , cache = cache )
26832685 # GH 21864
2684- expected = Index (malformed )
2686+ expected = Index (malformed , dtype = object )
26852687 tm .assert_index_equal (result , expected )
26862688
26872689 with pytest .raises (ValueError , match = msg ):
@@ -3670,7 +3672,7 @@ def test_to_datetime_mixed_not_necessarily_iso8601_raise():
36703672 ("errors" , "expected" ),
36713673 [
36723674 ("coerce" , DatetimeIndex (["2020-01-01 00:00:00" , NaT ])),
3673- ("ignore" , Index (["2020-01-01" , "01-01-2000" ])),
3675+ ("ignore" , Index (["2020-01-01" , "01-01-2000" ], dtype = object )),
36743676 ],
36753677)
36763678def test_to_datetime_mixed_not_necessarily_iso8601_coerce (errors , expected ):
0 commit comments