|
29 | 29 | ensure_platform_int,
|
30 | 30 | is_bool,
|
31 | 31 | is_bool_dtype,
|
32 |
| - is_categorical, |
33 | 32 | is_categorical_dtype,
|
34 | 33 | is_datetime64_any_dtype,
|
35 | 34 | is_dtype_equal,
|
@@ -532,6 +531,9 @@ def _shallow_copy_with_infer(self, values, **kwargs):
|
532 | 531 | return self._constructor(values, **attributes)
|
533 | 532 | except (TypeError, ValueError):
|
534 | 533 | pass
|
| 534 | + |
| 535 | + # Remove tz so Index will try non-DatetimeIndex inference |
| 536 | + attributes.pop("tz", None) |
535 | 537 | return Index(values, **attributes)
|
536 | 538 |
|
537 | 539 | def _update_inplace(self, result, **kwargs):
|
@@ -3870,50 +3872,6 @@ def _values(self) -> Union[ExtensionArray, np.ndarray]:
|
3870 | 3872 | """
|
3871 | 3873 | return self._data
|
3872 | 3874 |
|
3873 |
| - def _internal_get_values(self) -> np.ndarray: |
3874 |
| - """ |
3875 |
| - Return `Index` data as an `numpy.ndarray`. |
3876 |
| -
|
3877 |
| - Returns |
3878 |
| - ------- |
3879 |
| - numpy.ndarray |
3880 |
| - A one-dimensional numpy array of the `Index` values. |
3881 |
| -
|
3882 |
| - See Also |
3883 |
| - -------- |
3884 |
| - Index.values : The attribute that _internal_get_values wraps. |
3885 |
| -
|
3886 |
| - Examples |
3887 |
| - -------- |
3888 |
| - Getting the `Index` values of a `DataFrame`: |
3889 |
| -
|
3890 |
| - >>> df = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]], |
3891 |
| - ... index=['a', 'b', 'c'], columns=['A', 'B', 'C']) |
3892 |
| - >>> df |
3893 |
| - A B C |
3894 |
| - a 1 2 3 |
3895 |
| - b 4 5 6 |
3896 |
| - c 7 8 9 |
3897 |
| - >>> df.index._internal_get_values() |
3898 |
| - array(['a', 'b', 'c'], dtype=object) |
3899 |
| -
|
3900 |
| - Standalone `Index` values: |
3901 |
| -
|
3902 |
| - >>> idx = pd.Index(['1', '2', '3']) |
3903 |
| - >>> idx._internal_get_values() |
3904 |
| - array(['1', '2', '3'], dtype=object) |
3905 |
| -
|
3906 |
| - `MultiIndex` arrays also have only one dimension: |
3907 |
| -
|
3908 |
| - >>> midx = pd.MultiIndex.from_arrays([[1, 2, 3], ['a', 'b', 'c']], |
3909 |
| - ... names=('number', 'letter')) |
3910 |
| - >>> midx._internal_get_values() |
3911 |
| - array([(1, 'a'), (2, 'b'), (3, 'c')], dtype=object) |
3912 |
| - >>> midx._internal_get_values().ndim |
3913 |
| - 1 |
3914 |
| - """ |
3915 |
| - return self.values |
3916 |
| - |
3917 | 3875 | def _get_engine_target(self) -> np.ndarray:
|
3918 | 3876 | """
|
3919 | 3877 | Get the ndarray that we can pass to the IndexEngine constructor.
|
@@ -4657,10 +4615,8 @@ def get_indexer_non_unique(self, target):
|
4657 | 4615 | if pself is not self or ptarget is not target:
|
4658 | 4616 | return pself.get_indexer_non_unique(ptarget)
|
4659 | 4617 |
|
4660 |
| - if is_categorical(target): |
| 4618 | + if is_categorical_dtype(target.dtype): |
4661 | 4619 | tgt_values = np.asarray(target)
|
4662 |
| - elif self.is_all_dates and target.is_all_dates: # GH 30399 |
4663 |
| - tgt_values = target.asi8 |
4664 | 4620 | else:
|
4665 | 4621 | tgt_values = target._get_engine_target()
|
4666 | 4622 |
|
|
0 commit comments