Skip to content

Feature suggestion: unnest function for pandas #23470

Closed
@ghost

Description

It would really helpful if there's a function for unnesting lists in columns into it's own row while repeating other rows on length of the unnest. I know there are ways to solving this but a function would be a good idea.

A small example to demonstrate the unnest function.

## Sample dataframe.
df = pd.DataFrame({'id': [1,2,3],
              'name': [['test','test1','test2'],'test3','test4']})
print (df)

    id                 name
0   1   [test, test1, test2]
1   2                  test3
2   3                  test4

To,

## An example
unnest(df, on = 'name') 

    id   name
0   1    test
1   1   test1
2   1   test2
3   2   test3
4   3   test4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Duplicate ReportDuplicate issue or pull requestReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions