Im sorry if this question is similar to others asked in this forum, but I could not find a question similar enough. I have a df with 9 colums and 3 rows and I want to find all possible combinations between these rows. I have tried to use combinations from the itertools package but i can't seem to make it work. My desired output would be a list of all possible combinations. Thank you and sorry if it's similar to other questions asked.
import pandas as pd
from itertools import combinations
df1 = pd.DataFrame({"Main1": ["Outcome1", "Outcome2", "Outcome3"],
"Main2": ["Outcome1", "Outcome2", "Outcome3"],
"Main3": ["Outcome1", "Outcome2", "Outcome3"],
"Main4": ["Outcome1", "Outcome2", "Outcome3"],
"Main5": ["Outcome1", "Outcome2", "Outcome3"],
"Main6": ["Outcome1", "Outcome2", "Outcome3"],
"Main7": ["Outcome1", "Outcome2", "Outcome3"],
"Main8": ["Outcome1", "Outcome2", "Outcome3"],
"Main9": ["Outcome1", "Outcome2", "Outcome3"]})
Main1 Main2 Main3 Main4 Main5 Main6 Main7 Main8 Main9
0 Outcome1 Outcome1 Outcome1 Outcome1 Outcome1 Outcome1 Outcome1 Outcome1 Outcome1
1 Outcome2 Outcome2 Outcome2 Outcome2 Outcome2 Outcome2 Outcome2 Outcome2 Outcome2
2 Outcome3 Outcome3 Outcome3 Outcome3 Outcome3 Outcome3 Outcome3 Outcome3 Outcome3
all_combinations = list(combinations(df1, 3))
edit: Smaller sample and desired output:
df1 = pd.DataFrame({"Main1": ["Outcome1", "Outcome2", "Outcome3"], "Main2": ["Outcome1", "Outcome2", "Outcome3"]})
desired output something like this :
[["Outcome1","Outcome1"], ["Outcome1","Outcome2"], ["Outcome1","Outcome3"], ["Outcome2","Outcome1"], ["Outcome2","Outcome2"], ["Outcome2","Outcome3"], ["Outcome3","Outcome1"], ["Outcome3","Outcome2"], ["Outcome3","Outcome3"]]