Skip to content

Commit 663e82e

Browse files
Fix for issue pandas-dev#55509 (updating intersection only)
1 parent af5fa36 commit 663e82e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pandas/core/frame.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8857,11 +8857,11 @@ def update(
88578857
if not isinstance(other, DataFrame):
88588858
other = DataFrame(other)
88598859

8860-
other = other.reindex(self.index)
8860+
indexes_intersection = self.index.intersection(other.index)
88618861

88628862
for col in self.columns.intersection(other.columns):
8863-
this = self[col]._values
8864-
that = other[col]._values
8863+
this = self[col].loc[indexes_intersection]._values
8864+
that = other[col].loc[indexes_intersection]._values
88658865

88668866
if filter_func is not None:
88678867
mask = ~filter_func(this) | isna(that)
@@ -8881,7 +8881,7 @@ def update(
88818881
if mask.all():
88828882
continue
88838883

8884-
self.loc[:, col] = expressions.where(mask, this, that)
8884+
self[col].loc[indexes_intersection] = expressions.where(mask, this, that)
88858885

88868886
# ----------------------------------------------------------------------
88878887
# Data reshaping

0 commit comments

Comments
 (0)