diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 67456096e8681..5d15d33e7e215 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -3877,7 +3877,7 @@ def _join_monotonic(self, other, how="left", return_indexers=False): def _wrap_joined_index(self, joined, other): name = get_op_result_name(self, other) - return Index(joined, name=name) + return self._constructor(joined, name=name) # -------------------------------------------------------------------- # Uncategorized Methods diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index 7509cb35069e8..98ef473a13348 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -767,7 +767,8 @@ def _wrap_joined_index( self, joined: np.ndarray, other: "CategoricalIndex" ) -> "CategoricalIndex": name = get_op_result_name(self, other) - return self._create_from_codes(joined, name=name) + cat = self._data._from_backing_data(joined) + return type(self)._simple_new(cat, name=name) CategoricalIndex._add_logical_methods_disabled() diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index 54c8ed60b6097..13236f8488ecb 100644 --- a/pandas/core/indexes/datetimelike.py +++ b/pandas/core/indexes/datetimelike.py @@ -603,7 +603,9 @@ def _wrap_joined_index(self, joined: np.ndarray, other): else: self = cast(DatetimeTimedeltaMixin, self) freq = self.freq if self._can_fast_union(other) else None - new_data = type(self._data)._simple_new(joined, dtype=self.dtype, freq=freq) + + new_data = self._data._from_backing_data(joined) + new_data._freq = freq return type(self)._simple_new(new_data, name=name) diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index deeb7ff50b88c..7aceb898f5ccf 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -3637,7 +3637,7 @@ def delete(self, loc): def _wrap_joined_index(self, joined, other): names = self.names if self.names == other.names else None - return MultiIndex.from_tuples(joined, names=names) + return self._constructor(joined, names=names) @doc(Index.isin) def isin(self, values, level=None): diff --git a/pandas/core/indexes/numeric.py b/pandas/core/indexes/numeric.py index 125602ef2054a..e8b7efeee8852 100644 --- a/pandas/core/indexes/numeric.py +++ b/pandas/core/indexes/numeric.py @@ -33,7 +33,6 @@ from pandas.core import algorithms import pandas.core.common as com from pandas.core.indexes.base import Index, maybe_extract_name -from pandas.core.ops import get_op_result_name _num_index_shared_docs = dict() @@ -262,10 +261,6 @@ class Int64Index(IntegerIndex): _engine_type = libindex.Int64Engine _default_dtype = np.dtype(np.int64) - def _wrap_joined_index(self, joined, other): - name = get_op_result_name(self, other) - return Int64Index(joined, name=name) - @classmethod def _assert_safe_casting(cls, data, subarr): """ @@ -324,10 +319,6 @@ def _convert_index_indexer(self, keyarr): # ---------------------------------------------------------------- - def _wrap_joined_index(self, joined, other): - name = get_op_result_name(self, other) - return UInt64Index(joined, name=name) - @classmethod def _assert_safe_casting(cls, data, subarr): """