Skip to content

Commit 2af737a

Browse files
author
Marco Gorelli
committed
Remove special-casing multiindex
1 parent fe942e0 commit 2af737a

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

pandas/core/frame.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -6247,13 +6247,7 @@ def explode(self, column: Union[str, Tuple]) -> "DataFrame":
62476247
result = self.copy()
62486248
exploded_col = result.pop(column).reset_index(drop=True).explode()
62496249
result = result.reset_index().join(exploded_col)
6250-
6251-
if isinstance(self.index, ABCMultiIndex):
6252-
result.index = pandas.MultiIndex.from_frame(
6253-
result.iloc[:, : self.index.nlevels]
6254-
)
6255-
else:
6256-
result.index = result.iloc[:, 0]
6250+
result.set_index(result.columns[: self.index.nlevels].tolist(), inplace=True)
62576251
result.index.names = self.index.names
62586252
result = result.reindex(columns=self.columns, copy=False)
62596253

0 commit comments

Comments
 (0)