|
8 | 8 |
|
9 | 9 | from pandas._libs import NaT, Timedelta, iNaT, join as libjoin, lib
|
10 | 10 | from pandas._libs.tslibs import BaseOffset, Resolution, Tick, timezones
|
11 |
| -from pandas._libs.tslibs.parsing import DateParseError |
12 | 11 | from pandas._typing import Callable, Label
|
13 | 12 | from pandas.compat.numpy import function as nv
|
14 | 13 | from pandas.errors import AbstractMethodError
|
|
31 | 30 | from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin
|
32 | 31 | from pandas.core.base import IndexOpsMixin
|
33 | 32 | import pandas.core.common as com
|
34 |
| -from pandas.core.construction import array as pd_array, extract_array |
35 | 33 | import pandas.core.indexes.base as ibase
|
36 | 34 | from pandas.core.indexes.base import Index, _index_shared_docs
|
37 | 35 | from pandas.core.indexes.extension import (
|
@@ -586,19 +584,12 @@ def _wrap_joined_index(self, joined: np.ndarray, other):
|
586 | 584 |
|
587 | 585 | @doc(Index._convert_arr_indexer)
|
588 | 586 | def _convert_arr_indexer(self, keyarr):
|
589 |
| - if lib.infer_dtype(keyarr) == "string": |
590 |
| - # Weak reasoning that indexer is a list of strings |
591 |
| - # representing datetime or timedelta or period |
592 |
| - try: |
593 |
| - extension_arr = pd_array(keyarr, self.dtype) |
594 |
| - except (ValueError, DateParseError): |
595 |
| - # Fail to infer keyarr from self.dtype |
596 |
| - return keyarr |
597 |
| - |
598 |
| - converted_arr = extract_array(extension_arr, extract_numpy=True) |
599 |
| - else: |
600 |
| - converted_arr = com.asarray_tuplesafe(keyarr) |
601 |
| - return converted_arr |
| 587 | + try: |
| 588 | + return self._data._validate_listlike( |
| 589 | + keyarr, "convert_arr_indexer", cast_str=True, allow_object=True |
| 590 | + ) |
| 591 | + except (ValueError, TypeError): |
| 592 | + return com.asarray_tuplesafe(keyarr) |
602 | 593 |
|
603 | 594 |
|
604 | 595 | class DatetimeTimedeltaMixin(DatetimeIndexOpsMixin, Int64Index):
|
|
0 commit comments