I am trying to create out of a pandas dataframe a directed graph right now with networkx, so far i can use:
nx.from_pandas_edgelist(df, 'Activity', 'Activity followed', create_using=nx.DiGraph())
which shows me all the nodes and edges from Activity --> Activity followed.
In my dataframe there is sometimes the same activity followed by the same activity and i want to count this number in form of weights for the edges so far example this is my dataframe:
Index Activity Activityfollowed
0 Lunch Dinner
1 Lunch Dinner
2 Breakfast Lunch
should have the Edges:
Lunch --> Dinner (weight 2)
Breakfast --> Lunch (weight 1)
Is there any way to do it?