I'm trying to obtain the pair combinations of elements (list elements) within a DataFrame. I need to keep the first column to determine the original 'group' of the element pairs but splitting the element lists into element pairs in new rows.
I would have the following case:
| Group | X | |
|---|---|---|
| 0 | Group 1 | A,B,C |
| 1 | Group 2 | D,E |
| 2 | Group 3 | F,G,H,I |
And the output needs to be something like:
| Group | X | |
|---|---|---|
| 0 | Group 1 | A,B |
| 1 | Group 1 | A,C |
| 2 | Group 1 | B,C |
| 3 | Group 2 | D,E |
| 4 | Group 3 | F,G |
| 5 | Group 3 | F,H |
| 6 | Group 3 | F,I |
| 7 | Group 3 | G,H |
| 8 | Group 3 | G,I |
| 9 | Group 3 | H,I |
I would like to keep the Group column belonging to every combination. I don't know how to iterate through a DataFrame and keep that Group values in each row.




