Twitter-netwerken importeren en visualiseren

Socialmediagegevens analyseren in Python

Alex Hanna

Computational Social Scientist

Koppellijsten

         BethMohn           ChristianMohn
           ASilNY         LarrySchweikart
         mattg444              WhiteHouse
    hlthiskrieger                aravosis
          Herky86          SenJeffMerkley
  PatrickParsons9              TwitterGov
    New_Narrative                 CFR_org
           dddlor               roywoodjr
      scrivener50          michaelscherer
  ChiefsHeadCoach           johnpavlovitz
Socialmediagegevens analyseren in Python

Een retweet-netwerk importeren

import networkx as nx

## ... flatten and convert JSON
G_rt = nx.from_pandas_edgelist( tweets, source = 'user-screen_name', target = 'retweeted_status-user-screen_name', create_using = nx.DiGraph())
Socialmediagegevens analyseren in Python

Een quote-netwerk importeren

import networkx as nx

## ... flatten and convert JSON

G_quote = nx.from_pandas_edgelist( tweets, source = 'user-screen_name', target = 'quoted_status-user-screen_name', create_using = nx.DiGraph())
Socialmediagegevens analyseren in Python

Een reply-netwerk importeren

import networkx as nx

## ... flatten and convert JSON

G_reply = nx.from_pandas_edgelist(
                           tweets,
                           source = 'user-screen_name', 
                           target = 'in_reply_to_screen_name'
                           create_using = nx.DiGraph())
Socialmediagegevens analyseren in Python

Visualisatie

nx.draw_networkx(T)
plt.axis('off')

Gericht netwerk

Socialmediagegevens analyseren in Python

Visualisatie-opties

sizes = 
   [x[1]*100 for x in T.degree()]
nx.draw_networkx(T, 
            node_size = sizes, 
            with_labels = False, 
            alpha = 0.6,
            width = 0.3)
plt.axis('off')

Gericht netwerk aangepast

Socialmediagegevens analyseren in Python

Cirkellay-out

circle_pos =
    nx.circular_layout(T)
nx.draw_networkx(T,
            pos = circle_pos,
            node_size = sizes, 
            with_labels = False, 
            alpha = 0.6,
            width = 0.3)
plt.axis('off')

Gericht netwerk cirkellay-out

Socialmediagegevens analyseren in Python

Laten we oefenen!

Socialmediagegevens analyseren in Python

Preparing Video For Download...