I have checked online and on Stack Overflow and can't seem to get an answer for this. Assume I have a dataframe that looks as such:
colA colG
0 1 [a, b, c, d]
1 2 [c, d]
2 3 [e, f]
3 4 [g, h]
4 5 [i, j]
Is it possible to flatten colG
such that I get each letter assigned to a new row, something like:
colA colG colH
0 1 [a, b, c, d] a
1 1 [a, b, c, d] b
2 1 [a, b, c, d] c
3 1 [a, b, c, d] d
4 2 [c, d] c
5 2 [c, d] d
NB: The values for other columns other than the index remain consistent, with the aim of dropping the list of str column (colG
) after the operation