Skip to content

Commit f786763

Browse files
use difference not union to avoid sorting
1 parent c8ba339 commit f786763

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pandas/core/frame.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9185,10 +9185,9 @@ def _cast_large_numpy_ints_to_nullable(df: DataFrame) -> DataFrame:
91859185
return df.astype(cast_map) if cast_map else df
91869186

91879187
# Only cast frames whose index expand to the union (i.e., get <NA> on align)
9188-
union_index = self.index.union(other.index)
9189-
if not self.index.equals(union_index):
9188+
if len(other.index.difference(self.index, sort=False)):
91909189
self = _cast_large_numpy_ints_to_nullable(self)
9191-
if not other.index.equals(union_index):
9190+
if len(self.index.difference(other.index, sort=False)):
91929191
other = _cast_large_numpy_ints_to_nullable(other)
91939192

91949193
combined = self.combine(other, combiner, overwrite=False)

0 commit comments

Comments
 (0)