Skip to content

Commit eb437ea

Browse files
committed
DatetimeIndex get_loc validates date object
1 parent 3b1d4f1 commit eb437ea

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pandas/core/arrays/datetimes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import datetime, time, timedelta, tzinfo
1+
from datetime import datetime, date, time, timedelta, tzinfo
22
from typing import Optional, Union
33
import warnings
44

@@ -152,7 +152,7 @@ class DatetimeArray(dtl.DatetimeLikeArrayMixin, dtl.TimelikeOps, dtl.DatelikeOps
152152

153153
_typ = "datetimearray"
154154
_scalar_type = Timestamp
155-
_recognized_scalars = (datetime, np.datetime64)
155+
_recognized_scalars = (datetime, np.datetime64, date)
156156
_is_recognized_dtype = is_datetime64_any_dtype
157157

158158
# define my properties & methods for delegation

pandas/tests/indexes/datetimes/test_datetime.py

+7
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,10 @@ def test_split_non_utc(self):
402402
result = np.split(indices, indices_or_sections=[])[0]
403403
expected = indices._with_freq(None)
404404
tm.assert_index_equal(result, expected)
405+
406+
def test_in_contains_date_object(self):
407+
# GH#35466
408+
d1 = date(2002, 9, 1)
409+
idx1 = DatetimeIndex([d1])
410+
assert d1 in idx1
411+
assert "2002-09-01" in idx1

0 commit comments

Comments
 (0)