mardi 4 mai 2021

If statement with dataframe values

I want to make an if statement where if a username has two URLs that match it will build and edge. Usernames is a column in the dataframe(tweets_). URLs is a column as well in the dataframe.

import pandas as pd
import re,os
import numpy as np
import networkx as nx

# dictionary where values are list
from collections import defaultdict

# plotting
import matplotlib.pyplot as plt
import seaborn as sns

tweets_=pd.read_csv('TwitterLinksNWO.csv')


#How would I create this if statement?


US_graph = nx.from_pandas_edgelist(tweets_,source="username", target="urls")
type(US_graph)
nx.info(US_graph)
plt.figure(figsize=(40,40))
nx.draw_networkx(US_graph)
plt.show

Aucun commentaire:

Enregistrer un commentaire