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(
173173 1 b B E 3
174174 2 c B E 5
175175 """
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+
179177 if value_name in frame .columns :
180178 raise ValueError (
181179 f"value_name ({ value_name } ) cannot match an element in "
@@ -185,6 +183,10 @@ def melt(
185183 value_vars_was_not_none = value_vars is not None
186184 value_vars = ensure_list_vars (value_vars , "value_vars" , frame .columns )
187185
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+
188190 if id_vars or value_vars :
189191 if col_level is not None :
190192 level = frame .columns .get_level_values (col_level )
You can’t perform that action at this time.
0 commit comments