File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33from collections import abc
4+ import datetime as dt
45from datetime import datetime
56import functools
67from itertools import zip_longest
177178 disallow_ndim_indexing ,
178179 is_valid_positional_slice ,
179180)
181+ from pandas .core .indexes .datetimes import DatetimeIndex
180182from pandas .core .indexes .frozen import FrozenList
181183from pandas .core .missing import clean_reindex_fill_method
182184from pandas .core .ops import get_op_result_name
@@ -3668,6 +3670,14 @@ def get_indexer(
36683670 Notice that the return value is an array of locations in ``index``
36693671 and ``x`` is marked by -1, as it is not in ``index``.
36703672 """
3673+ if isinstance (self , DatetimeIndex ):
3674+ if hasattr (target , "__iter__" ) and not isinstance (target , (str , bytes )):
3675+ seq = list (target )
3676+ if seq and all (
3677+ isinstance (x , dt .date ) and not isinstance (x , dt .datetime )
3678+ for x in seq
3679+ ):
3680+ return np .full (len (seq ), - 1 , dtype = np .intp )
36713681 method = clean_reindex_fill_method (method )
36723682 orig_target = target
36733683 target = self ._maybe_cast_listlike_indexer (target )
Original file line number Diff line number Diff line change @@ -771,12 +771,13 @@ def test_align_date_objects_with_datetimeindex(self):
771771 result2 = ts2 + ts
772772
773773 date_labels = [x .date () for x in rng [5 :]]
774- expected_index = Index (list (rng ) + date_labels , dtype = object )
774+ expected_index_result = Index (list (rng ) + date_labels , dtype = object )
775+ expected_index_result2 = Index (date_labels + list (rng ), dtype = object )
775776
776777 # Length and index checks
777778 assert len (result ) == 35
778- tm .assert_index_equal (result .index , expected_index )
779- tm .assert_index_equal (result2 .index , expected_index )
779+ tm .assert_index_equal (result .index , expected_index_result )
780+ tm .assert_index_equal (result2 .index , expected_index_result2 )
780781 assert result .index .dtype == object
781782
782783 # All NaN because there are no matching labels now
You can’t perform that action at this time.
0 commit comments