Skip to content

Commit 80ba8b5

Browse files
Revert "Override RangeIndex._find_common_type_compat"
This reverts commit 102644c.
1 parent 102644c commit 80ba8b5

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
@@ -6256,6 +6256,7 @@ def _maybe_promote(self, other: Index) -> tuple[Index, Index]:
62566256

62576257
return self, other
62586258

6259+
@final
62596260
def _find_common_type_compat(self, target) -> DtypeObj:
62606261
"""
62616262
Implementation of find_common_type that adjusts for Index-specific

pandas/core/indexes/range.py

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

30-
from pandas.core.dtypes.cast import (
31-
find_common_type,
32-
infer_dtype_from,
33-
)
3430
from pandas.core.dtypes.common import (
3531
ensure_platform_int,
3632
ensure_python_int,
@@ -55,14 +51,12 @@
5551
from pandas._typing import (
5652
Axis,
5753
Dtype,
58-
DtypeObj,
5954
NaPosition,
6055
Self,
6156
npt,
6257
)
6358
_empty_range = range(0)
6459
_dtype_int64 = np.dtype(np.int64)
65-
_dtype_obj = np.dtype("object")
6660

6761

6862
class RangeIndex(Index):
@@ -1155,21 +1149,3 @@ def take(
11551149

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

0 commit comments

Comments
 (0)