Fast and easy social graphs from tweets
To install using pip, use
pip install tweet2graph
- Import the library:
from tweet2graph import Tweets2Graph
- Choose which interaction between users are relevant for you:
backend = Tweets2Graph(interactions=["retweet","quote","reply"], #relevant interactions
username="screen_name") #name of the nodes
- Load dataset
#load a single .csv/.json file
backend.from_file("examples/csv/1614874276.csv")
#load a folder
backend.from_folder("examples/csv/")
#load from a mongodb collections
backend.from_mongo(connection_string='<CONNECTION_STRING>',
database='<DB_NAME>',
collection='<COLLECTION_NAME>')
#or from a pandas dataframe
backend.from_dataframe(dataframe)
-
Fit/Transform
#organize data backend.fit() #create graph graph = backend.transform() #or simply graph = backend.fit_transform()
-
Show and save
import networkx as nx nx.draw(graph,with_labels=False,node_size=5,font_size=5,font_color="red",node_color="black") nx.write_adjlist(G=graph)
- add connected component
-
.from_user('<USER_NAME>')
method - Add metadata to tweet
- Insert mentions in possible interactions
- Add custom error and better explanation
- Add speed benchmark and figures
- Add
.from_stream(id="<hashtag>")
method - Update
.from_stream(id="<hashtag>")
with two distinct processes - Dockerfile