Skip to content
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

Adjust test in tools for new string option #56178

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions pandas/tests/tools/test_to_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
Loading