Sample dataframe as below
df = pd.DataFrame({'ID': ['a', 'a', 'a', 'b', 'b', 'c', 'c'],
'color': ['red', 'blue', 'green', 'red', 'blue', 'red', 'green']})
I want 2 columns with all combinations of the color field after grouping by ID.
I want the resultant dataframe as shown below
| ID | color1 | color2 |
|---|---|---|
| a | red | blue |
| a | red | green |
| a | blue | red |
| a | blue | green |
| a | green | red |
| a | green | blue |
| b | red | blue |
| b | blue | red |
| c | red | green |
| c | green | red |
I have tried using itertools.permutations but am looking for something more direct or for a solution that utilizes Pandas more.