0

I need to change below dataframe:

input

I want the output in below form:

OUTPUT

I tried to use itertools.combinations_with_replacement to get all combination

from itertools import combinations_with_replacement comb = list(combinations_with_replacement(pairwise_similarity_df.index,2))

matrix is 10000*10000 so i expected 100000000 rows but got only 50005000.

how can i convert this to required format?

1 Answers1

0

Thanks Gionni,

Below code worked for me:

df['company1']=df.index

df=df.melt(id_vars["company1"],var_name="company2")

enter image description here