Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
ZanirP wants to merge1 commit intopandas-dev:main
base:main
Choose a base branch
Loading
fromZanirP:melt_error_duplicate_columns

Conversation

ZanirP
Copy link

@ZanirPZanirP commentedMay 23, 2025
edited
Loading

Comment on lines +242 to +244
# GH61475 - prevent AttributeError when duplicate column
ifnothasattr(id_data,"dtype"):
raiseException(f"{col} is a duplicate column header")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

  1. This should checkif not frame.columns.is_unique at the beginning of the function.
  2. AValueError is more appropriate here

Copy link
Author

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?

Copy link
Member

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

@mroeschkemroeschke added ReshapingConcat, Merge/Join, Stack/Unstack, Explode Error ReportingIncorrect or improved errors from pandas labelsMay 23, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mroeschkemroeschkemroeschke left review comments

Assignees
No one assigned
Labels
Error ReportingIncorrect or improved errors from pandasReshapingConcat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

BUG: More Indicative Error when pd.melt with duplicate columns
2 participants
@ZanirP@mroeschke

[8]ページ先頭

©2009-2025 Movatter.jp