Skip to content

Commit 4f4d6b1

Browse files
committed
Fix: Add error handling for query with duplicate columns
1 parent 70edaa0 commit 4f4d6b1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pandas/core/frame.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4616,6 +4616,8 @@ def query(self, expr: str, *, inplace: bool = False, **kwargs) -> DataFrame | No
46164616
0 1 10 10
46174617
1 2 8 9
46184618
"""
4619+
if self.columns.duplicated().any():
4620+
raise ValueError("DataFrame contains duplicate column names.")
46194621
inplace = validate_bool_kwarg(inplace, "inplace")
46204622
if not isinstance(expr, str):
46214623
msg = f"expr must be a string to be evaluated, {type(expr)} given"

0 commit comments

Comments
 (0)