I have the following code as an example (this is based on pairwise similarity of textual definitions):
import pandas as pd
df = pd.read_csv("pairings.csv")
sample_list = df['fruit'].tolist()
And the output of sample_list looks like:
['Apple, Orange', 'Pear, Apple, Grape',
'Plum, Orange, Pear, Banana, Grape, Apple']
Again I arbitrarily selected fruits as an example, my actual dataset finds the groupings between techniques based on cosine similarity and produces groupings of the techniques based on their definitions.
I have tried
for n in range(len(sample_list) + 1):
list_combinations += list(combinations(sample_list,n))
print(list_combinations)
and
for i in sample_test:
res = [(a, b) for idx, a in enumerate(sample_test) for b in sample_test[idx + 1:]]
But they have not worked. My goal is to get a new csv that shows all the pairs of each list within the list so it would read as (the brackets would not be there this is just for further explanation):
0 1
0 Apple Orange [from list 1]
1 Pear Apple [from list 2]
2 Pear Grape [from list 2]
3 Apple Grape [from list 2]
4 Plum Orange [from list 3]
5 Plum Pear [from list 3]
6 etc.
I need to know how to iterate through each list and get all possible pairs. Thanks!