I have generated a co-occurrence matrix by using the Python pandas library, with the following code:
# dfdo is an ordered dictionary with a key called KEY453
df = pd.DataFrame(dfdo).set_index('KEY453')
df_asint = df.astype(int)
com = df_asint.T.dot(df_asint)
It follows the same procedure as this question.
My question is, how can I find the top 2 strings which co-occur with a given string in the matrix? For example, The top 2 strings that co-occur with Dog in the example below are Cat and Zebra.
Cat Dog Zebra
Cat 0 2 3
Dog 2 0 1
Zebra 3 1 0