Skip to content

Commit fe942e0

Browse files
author
Marco Gorelli
committed
Rephrase whatsnew entry, name copy of self result rather than frame
1 parent fa43c93 commit fe942e0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

doc/source/whatsnew/v1.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Indexing
142142
^^^^^^^^
143143

144144
- Bug in assignment using a reverse slicer (:issue:`26939`)
145-
- Frame gets duplicated when exploding a single column and there are duplicates in the index (:issue:`28010`)
145+
- Bug in :meth:`DataFrame.explode` would duplicate frame in the presence of duplicates in the index (:issue:`28010`)
146146

147147
Missing
148148
^^^^^^^

pandas/core/frame.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6244,9 +6244,9 @@ def explode(self, column: Union[str, Tuple]) -> "DataFrame":
62446244
if not self.columns.is_unique:
62456245
raise ValueError("columns must be unique")
62466246

6247-
frame = self.copy()
6248-
exploded_col = frame.pop(column).reset_index(drop=True).explode()
6249-
result = frame.reset_index().join(exploded_col)
6247+
result = self.copy()
6248+
exploded_col = result.pop(column).reset_index(drop=True).explode()
6249+
result = result.reset_index().join(exploded_col)
62506250

62516251
if isinstance(self.index, ABCMultiIndex):
62526252
result.index = pandas.MultiIndex.from_frame(

0 commit comments

Comments
 (0)