Skip to content

Commit 1ccd4cf

Browse files
jbrockmendelmeeseeksmachine
authored andcommitted
Backport PR pandas-dev#41972: PERF: indexing on UInt64Index with int64s
1 parent 5d54969 commit 1ccd4cf

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/core/indexes/base.py

+7
Original file line numberDiff line numberDiff line change
@@ -5303,6 +5303,13 @@ def _maybe_promote(self, other: Index) -> tuple[Index, Index]:
53035303
if not is_object_dtype(self.dtype):
53045304
return self.astype("object"), other.astype("object")
53055305

5306+
elif self.dtype.kind == "u" and other.dtype.kind == "i":
5307+
# GH#41873
5308+
if other.min() >= 0:
5309+
# lookup min as it may be cached
5310+
# TODO: may need itemsize check if we have non-64-bit Indexes
5311+
return self, other.astype(self.dtype)
5312+
53065313
if not is_object_dtype(self.dtype) and is_object_dtype(other.dtype):
53075314
# Reverse op so we dont need to re-implement on the subclasses
53085315
other, self = other._maybe_promote(self)

0 commit comments

Comments
 (0)