Skip to content

Commit 46821e8

Browse files
author
Jake Stevens-Haas
committed
BUG: GH37635
Previously, the variable "cols" was created solely to concatenate the lists "index" and "columns" when the "values" parameter was left as None. It did so in a way that it modified the variable passed as "index" using list.extend(), affecting the caller's namespace. This change simply uses an anonymous list in place of the variable "cols"
1 parent 44406a6 commit 46821e8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pandas/core/reshape/pivot.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,13 +447,12 @@ def pivot(
447447

448448
if values is None:
449449
if index is not None:
450-
cols = com.convert_to_list_like(index)
450+
index = com.convert_to_list_like(index)
451451
else:
452-
cols = []
453-
cols.extend(columns)
452+
index = []
454453

455454
append = index is None
456-
indexed = data.set_index(cols, append=append)
455+
indexed = data.set_index(index + columns, append=append)
457456
else:
458457
if index is None:
459458
index = [Series(data.index, name=data.index.name)]

0 commit comments

Comments
 (0)