2

In my code I built nodes, username, and urlsCleaned with the edges being between the username and urlsCleaned. I want to build the edges between urls to other urls(urls being the nodes). The way I want the edges to be built is if a user in the dataframe NWO_data uses two separate urls in different tweets then it should build the edge between the url nodes. How would I go about doing this? The dataframe has these columns: username, name, tweet, language, mentions, urls, replies_count retweets_count, likes_count, hashtags, link, retweet. The same user can be in multiple rows because they can have multiple tweets.

import csv
import twint
import datetime
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import nest_asyncio
import re
nest_asyncio.apply()

NWO_data = pd.read_csv("TwitterLinksNWO.csv")

NWO_data["urlsCleaned"] = NWO_data["urls"]

import networkx as nx
US_graph = nx.from_pandas_edgelist(NWO_data,source="username", target="urlsCleaned")
type(US_graph)
nx.info(US_graph)
plt.figure(figsize=(40,40))
nx.draw_networkx(US_graph)
plt.show
  • what do you have in dataframe? You could show some example data - as text - and then we can use it to check ideas. – furas Apr 27 '21 at 04:19
  • it title you want build edges between users but in question you want to create edges between urls. Which one you want. Maybe you should ilustrate it using some data or draw image with graph. – furas Apr 27 '21 at 04:22

0 Answers0