Skip to content

Commit 6d07b0c

Browse files
Revert "Override RangeIndex._find_common_type_compat"
This reverts commit 102644c.
1 parent a8a013a commit 6d07b0c

File tree

2 files changed

+1
-24
lines changed

2 files changed

+1
-24
lines changed

pandas/core/indexes/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -6273,6 +6273,7 @@ def _maybe_promote(self, other: Index) -> tuple[Index, Index]:
62736273

62746274
return self, other
62756275

6276+
@final
62766277
def _find_common_type_compat(self, target) -> DtypeObj:
62776278
"""
62786279
Implementation of find_common_type that adjusts for Index-specific

pandas/core/indexes/range.py

-24
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
doc,
2929
)
3030

31-
from pandas.core.dtypes.cast import (
32-
find_common_type,
33-
infer_dtype_from,
34-
)
3531
from pandas.core.dtypes.common import (
3632
ensure_platform_int,
3733
ensure_python_int,
@@ -56,14 +52,12 @@
5652
from pandas._typing import (
5753
Axis,
5854
Dtype,
59-
DtypeObj,
6055
NaPosition,
6156
Self,
6257
npt,
6358
)
6459
_empty_range = range(0)
6560
_dtype_int64 = np.dtype(np.int64)
66-
_dtype_obj = np.dtype("object")
6761

6862

6963
class RangeIndex(Index):
@@ -1158,21 +1152,3 @@ def take(
11581152

11591153
# _constructor so RangeIndex-> Index with an int64 dtype
11601154
return self._constructor._simple_new(taken, name=self.name)
1161-
1162-
def _find_common_type_compat(self, target) -> DtypeObj:
1163-
target_dtype, _ = infer_dtype_from(target)
1164-
1165-
# special case: if one dtype is uint64 and the other a signed int, return object
1166-
# See https://github.com/pandas-dev/pandas/issues/26778 for discussion
1167-
# Now it's:
1168-
# * float | [u]int -> float
1169-
# * uint64 | signed int -> object
1170-
# We may change union(float | [u]int) to go to object.
1171-
if self.dtype == "uint64" or target_dtype == "uint64":
1172-
if is_signed_integer_dtype(self.dtype) or is_signed_integer_dtype(
1173-
target_dtype
1174-
):
1175-
return _dtype_obj
1176-
1177-
dtype = find_common_type([self.dtype, target_dtype])
1178-
return dtype

0 commit comments

Comments
 (0)