Skip to content

ENH: (explode) Splitting a column content over multiple rows while duplicating other columns content to these rows #16538

Closed
@BLMeltdown

Description

@BLMeltdown

Hello
I know it is not a problem per se but I think there should be some pandas built in solution for this problem, as no simple function exists for this.
It is largely discussed here with various ideas (https://stackoverflow.com/questions/12680754/split-pandas-dataframe-string-entry-to-separate-rows) but they are quite tricky actually, not using built in things but hacking normal behavior for the most part.

I believe that could use some strategy drawn from the reindexing/filling functions, but as I am not a Pandas specialist, I am not sure this would use the most efficient function to perform this task.

Let's say we have

df

var1  var2

0 a,b,c x
1 d,e,f y
df.desired_function("var1")

var1 var2
0 a x
1 b x
2 c x
3 d y
4 e y
5 f y

Best regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions