Skip to content

Commit 75e8fee

Browse files
BUG: Added test and release note pandas-dev#45319
1 parent 6dc5d48 commit 75e8fee

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

doc/source/whatsnew/v1.5.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ Datetimelike
827827
- Bug in :meth:`DatetimeIndex.resolution` incorrectly returning "day" instead of "nanosecond" for nanosecond-resolution indexes (:issue:`46903`)
828828
- Bug in :class:`Timestamp` with an integer or float value and ``unit="Y"`` or ``unit="M"`` giving slightly-wrong results (:issue:`47266`)
829829
- Bug in :class:`.DatetimeArray` construction when passed another :class:`.DatetimeArray` and ``freq=None`` incorrectly inferring the freq from the given array (:issue:`47296`)
830-
-
830+
- Bug in :func:`to_datetime` where ``OutOfBoundsDatetime`` would be thrown even if ``errors=coerce`` if there were more than 50 rows (:issue:`45319`)
831831

832832
Timedelta
833833
^^^^^^^^^

pandas/tests/tools/test_to_datetime.py

+20
Original file line numberDiff line numberDiff line change
@@ -2773,3 +2773,23 @@ def test_to_datetime_monotonic_increasing_index(cache):
27732773
result = to_datetime(times.iloc[:, 0], cache=cache)
27742774
expected = times.iloc[:, 0]
27752775
tm.assert_series_equal(result, expected)
2776+
2777+
2778+
@pytest.mark.parametrize(
2779+
"input",
2780+
[
2781+
Series(
2782+
[datetime.fromisoformat("1446-04-12 00:00:00+00:00")]
2783+
+ ([datetime.fromisoformat("1991-10-20 00:00:00+00:00")] * 40)
2784+
),
2785+
Series(
2786+
[datetime.fromisoformat("1446-04-12 00:00:00+00:00")]
2787+
+ ([datetime.fromisoformat("1991-10-20 00:00:00+00:00")] * 50)
2788+
),
2789+
],
2790+
)
2791+
def test_to_datetime_cache_coerce_50_lines(input):
2792+
# GH#45319
2793+
result = to_datetime(input, errors="coerce", utc=True)
2794+
2795+
assert result[0] is NaT

0 commit comments

Comments
 (0)