Skip to content

Test to datetime null to NaT #45512

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

Merged
merged 13 commits into from
Feb 1, 2022
Merged
19 changes: 19 additions & 0 deletions pandas/tests/tools/test_to_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,25 @@ def test_convert_object_to_datetime_with_cache(
)
tm.assert_series_equal(result_series, expected_series)

@pytest.mark.parametrize("cache", [True, False])
@pytest.mark.parametrize(
("input", "expected"),
(
(
Series([NaT] * 200 + [None] * 200, dtype="object"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind using less values here? (20/40 should be good)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we have a predefined breakpoitn with 50 values?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but IIRC that's needed when specifically testing caching behavior

Series([NaT] * 400, dtype="datetime64[ns]"),
),
(Series([None] * 200), Series([NaT] * 200, dtype="datetime64[ns]")),
(Series([""] * 200), Series([NaT] * 200, dtype="datetime64[ns]")),
(Series([pd.NA] * 200), Series([NaT] * 200, dtype="datetime64[ns]")),
(Series([np.NaN] * 200), Series([NaT] * 200, dtype="datetime64[ns]")),
),
)
def test_to_datetime_converts_null_like_to_nat(self, cache, input, expected):
# GH35888
result = to_datetime(input, cache=cache)
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize(
"date, format",
[
Expand Down