From 009de8babfb2904ed818504d3e4b05ab19d77d21 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Sun, 26 Nov 2023 18:19:14 +0100 Subject: [PATCH] Adjust test in tools for new string option --- pandas/tests/tools/test_to_datetime.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pandas/tests/tools/test_to_datetime.py b/pandas/tests/tools/test_to_datetime.py index 503032293dc81..ee209f74eb4e0 100644 --- a/pandas/tests/tools/test_to_datetime.py +++ b/pandas/tests/tools/test_to_datetime.py @@ -183,7 +183,7 @@ def test_to_datetime_format_YYYYMMDD_ignore_with_outofbounds(self, cache): errors="ignore", cache=cache, ) - expected = Index(["15010101", "20150101", np.nan]) + expected = Index(["15010101", "20150101", np.nan], dtype=object) tm.assert_index_equal(result, expected) def test_to_datetime_format_YYYYMMDD_coercion(self, cache): @@ -1206,7 +1206,9 @@ def test_out_of_bounds_errors_ignore2(self): # GH#12424 msg = "errors='ignore' is deprecated" with tm.assert_produces_warning(FutureWarning, match=msg): - res = to_datetime(Series(["2362-01-01", np.nan]), errors="ignore") + res = to_datetime( + Series(["2362-01-01", np.nan], dtype=object), errors="ignore" + ) exp = Series(["2362-01-01", np.nan], dtype=object) tm.assert_series_equal(res, exp) @@ -1489,7 +1491,7 @@ def test_datetime_invalid_index(self, values, format): warn, match="Could not infer format", raise_on_extra_warnings=False ): res = to_datetime(values, errors="ignore", format=format) - tm.assert_index_equal(res, Index(values)) + tm.assert_index_equal(res, Index(values, dtype=object)) with tm.assert_produces_warning( 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): "errors, expected", [ ("coerce", Index([NaT, NaT])), - ("ignore", Index(["200622-12-31", "111111-24-11"])), + ("ignore", Index(["200622-12-31", "111111-24-11"], dtype=object)), ], ) def test_to_datetime_malformed_no_raise(self, errors, expected): @@ -2681,7 +2683,7 @@ def test_string_na_nat_conversion_malformed(self, cache): result = to_datetime(malformed, errors="ignore", cache=cache) # GH 21864 - expected = Index(malformed) + expected = Index(malformed, dtype=object) tm.assert_index_equal(result, expected) with pytest.raises(ValueError, match=msg): @@ -3670,7 +3672,7 @@ def test_to_datetime_mixed_not_necessarily_iso8601_raise(): ("errors", "expected"), [ ("coerce", DatetimeIndex(["2020-01-01 00:00:00", NaT])), - ("ignore", Index(["2020-01-01", "01-01-2000"])), + ("ignore", Index(["2020-01-01", "01-01-2000"], dtype=object)), ], ) def test_to_datetime_mixed_not_necessarily_iso8601_coerce(errors, expected):