I have a pandas dataframe called df_sort with the following structure,
Structure:
Topic Links Topic_method_1
ML Data Mining 1
ML Data Analysis 1
ML ggplot2 2
ML R 3
ML python 3
Question:
I want to create a network graph for my dataframe and color the nodes by the values of column 'Topic_method_1'
Attempt so far:
import networkx as nx
import matplotlib.pyplot as plt
# Build your graph
G=nx.from_pandas_edgelist(df_sort, 'Topic', 'Links')
# Plot it
nx.draw(G, with_labels=True)
plt.show()
Problem:
How do I add colors to my nodes? I see that there is a node_attribute in the documentation.