As @ALollz has mentioned in the comments, you can use G=nx.from_pandas_adjacency(df)
to create a graph from your pandas dataframe and then visualize it with pyvis.network
as follows:
import pandas as pd
import numpy as np
import networkx as nx
from pyvis.network import Network
# creating a dummy adjacency matrix of shape 20x20 with random values of 0 to 3
adj_mat = np.random.randint(0, 3, size=(20, 20))
np.fill_diagonal(adj_mat, 0) # setting the diagonal values as 0
df = pd.DataFrame(adj_mat)
# create a graph from your dataframe
G = nx.from_pandas_adjacency(df)
# visualize it with pyvis
N = Network(height='100%', width='100%', bgcolor='#222222', font_color='white')
N.barnes_hut()
for n in G.nodes:
N.add_node(int(n))
for e in G.edges:
N.add_edge(int(e[0]), int(e[1]))
N.write_html('./coocc-graph.html')
