ENH: (explode) Splitting a column content over multiple rows while duplicating other columns content to these rows · Issue #16538 · pandas-dev/pandas (original) (raw)
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