Skip to content

Commit 2635c05

Browse files
BUG: Raise dupl. + no common idx on update pandas-dev#55509
1 parent c7958e0 commit 2635c05

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pandas/core/frame.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -8859,10 +8859,22 @@ def update(
88598859
other = DataFrame(other)
88608860

88618861
indexes_intersection = self.index.intersection(other.index)
8862+
if not len(indexes_intersection):
8863+
raise ValueError(
8864+
"Can't update dataframe when other has no element in common."
8865+
)
88628866

88638867
for col in self.columns.intersection(other.columns):
8864-
this = self.loc[indexes_intersection, col]._values
8865-
that = other.loc[indexes_intersection, col]._values
8868+
this = self.loc[indexes_intersection, col]
8869+
that = other.loc[indexes_intersection, col]
8870+
8871+
if this.index.has_duplicates or that.index.has_duplicates:
8872+
raise ValueError(
8873+
"Update not allowed with duplicate indexes on dataframe or other."
8874+
)
8875+
8876+
this = this._values
8877+
that = that._values
88668878

88678879
if filter_func is not None:
88688880
mask = ~filter_func(this) | isna(that)

0 commit comments

Comments
 (0)