Skip to content

Commit 825e34f

Browse files
author
mcortesdf
committed
add test for pandas-dev#9107
test to ensure OutOfBoundsDatetime exception is raised when calling pd.to_datetime with out-of-bounds date strings
1 parent 3cf1757 commit 825e34f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

doc/source/whatsnew/v1.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Datetimelike
118118
- Bug in :meth:`pandas.core.groupby.SeriesGroupBy.nunique` where ``NaT`` values were interfering with the count of unique values (:issue:`27951`)
119119
- Bug in :class:`Timestamp` subtraction when subtracting a :class:`Timestamp` from a ``np.datetime64`` object incorrectly raising ``TypeError`` (:issue:`28286`)
120120
- Addition and subtraction of integer or integer-dtype arrays with :class:`Timestamp` will now raise ``NullFrequencyError`` instead of ``ValueError`` (:issue:`28268`)
121-
-
121+
- New test to ensure OutOfBoundsDatetime exception is raised when calling :func:``pd.to_datetime`` with out-of-bounds date strings
122122

123123

124124
Timedelta

pandas/tests/indexes/datetimes/test_tools.py

+6
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,12 @@ def test_to_datetime_box_deprecated(self):
10281028
result = pd.to_datetime(expected).to_datetime64()
10291029
assert result == expected
10301030

1031+
@pytest.mark.parametrize("dt_str", ["00010101", "13000101", "30000101", "99990101"])
1032+
def test_old_date_out_of_bounds_exception(self, dt_str):
1033+
# GH 9107
1034+
with pytest.raises(OutOfBoundsDatetime):
1035+
pd.to_datetime(dt_str, format="%Y%m%d")
1036+
10311037

10321038
class TestToDatetimeUnit:
10331039
@pytest.mark.parametrize("cache", [True, False])

0 commit comments

Comments
 (0)