Skip to content

Commit 09fa1a0

Browse files
author
Kyle Stahl
authored
Merge pull request #4 from stahl085/explode-multiple-column
ENH: DataFrame.explode() multiple columns
2 parents 2c127cb + fa0df42 commit 09fa1a0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pandas/core/frame.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6207,14 +6207,15 @@ def stack(self, level=-1, dropna=True):
62076207

62086208
def explode(self, columns: Union[str, List[str]]) -> "DataFrame":
62096209
"""
6210-
Transform each element of a list-like to a row, replicating the index values.
6210+
Transform each element of a list-like to a row, replicating index values.
62116211
62126212
.. versionadded:: 0.25.0
62136213
62146214
Parameters
62156215
----------
6216-
column : str or tuple
6217-
6216+
columns : str or list
6217+
the column(s) to be exploded
6218+
62186219
Returns
62196220
-------
62206221
DataFrame
@@ -6298,7 +6299,7 @@ def explode(self, columns: Union[str, List[str]]) -> "DataFrame":
62986299
lengths_equal = []
62996300

63006301
for row in self[columns].iterrows():
6301-
# converts non-lists into 1 element lists
6302+
# converts non-lists into 1 element lists so len() is valid
63026303
r=row[1].apply(lambda x: x if type(x) in (list,tuple) else [x])
63036304

63046305
# make sure all lists in the same record are the same length

0 commit comments

Comments
 (0)