I have a pandas dataframe (df) of the form-
Col1
A [Green,Red,Purple]
B [Red, Yellow, Blue]
C [Brown, Green, Yellow, Blue]
I need to convert this to an edge list i.e. a dataframe of the form:
Source Target Weight
A B 1
A C 1
B C 2
EDIT Note that the new dataframe has rows equal to the total number of possible pairwise combinations. Also, to compute the 'Weight' column, we simply find the intersection between the two lists. For instance, for B&C, the elements share two colors: Blue and Yellow. Therefore, the 'Weight' for the corresponding row is 2.
What is the fastest way to do this? The original dataframe contains about 28,000 elements.