Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork18.5k
BUG: Raise clear error for duplicate id_vars in melt (GH61475)#61484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
# GH61475 - prevent AttributeError when duplicate column | ||
ifnothasattr(id_data,"dtype"): | ||
raiseException(f"{col} is a duplicate column header") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
- This should check
if not frame.columns.is_unique
at the beginning of the function. - A
ValueError
is more appropriate here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks for the feedback! I've moved the check fornot frame.columns.is_unique
to the beginning of the function and updated the exception type toValueError
as suggested.
A quick clarification question: currentlymelt
allows duplicate column names in 'value_vars', as seen in the testtest_melt_with_duplicate_columns
.With this change, are we treating any duplicate columns in the inputDataFrame
as aValueError
? Not just when the duplicates appear inid_vars
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ah good point. I guess this specifically whenid_vars
is not empty we'll want to raiseif not frame.columns.is_unique
Uh oh!
There was an error while loading.Please reload this page.
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.