File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -173,9 +173,7 @@ def melt(
173
173
1 b B E 3
174
174
2 c B E 5
175
175
"""
176
- # GH61475 - prevent AttributeError when duplicate column in id_vars
177
- if id_vars and any (frame .columns .tolist ().count (col ) > 1 for col in id_vars ):
178
- raise ValueError ("id_vars cannot contain duplicate columns." )
176
+
179
177
if value_name in frame .columns :
180
178
raise ValueError (
181
179
f"value_name ({ value_name } ) cannot match an element in "
@@ -185,6 +183,10 @@ def melt(
185
183
value_vars_was_not_none = value_vars is not None
186
184
value_vars = ensure_list_vars (value_vars , "value_vars" , frame .columns )
187
185
186
+ # GH61475 - prevent AttributeError when duplicate column in id_vars
187
+ if len (frame .columns .get_indexer_for (id_vars )) > len (id_vars ):
188
+ raise ValueError ("id_vars cannot contain duplicate columns." )
189
+
188
190
if id_vars or value_vars :
189
191
if col_level is not None :
190
192
level = frame .columns .get_level_values (col_level )
You can’t perform that action at this time.
0 commit comments