트위터 네트워크 가져오기 및 시각화

Python으로 소셜 미디어 데이터 분석하기

Alex Hanna

Computational Social Scientist

엣지 리스트

         BethMohn           ChristianMohn
           ASilNY         LarrySchweikart
         mattg444              WhiteHouse
    hlthiskrieger                aravosis
          Herky86          SenJeffMerkley
  PatrickParsons9              TwitterGov
    New_Narrative                 CFR_org
           dddlor               roywoodjr
      scrivener50          michaelscherer
  ChiefsHeadCoach           johnpavlovitz
Python으로 소셜 미디어 데이터 분석하기

리트윗 네트워크 가져오기

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())
Python으로 소셜 미디어 데이터 분석하기

인용 네트워크 가져오기

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())
Python으로 소셜 미디어 데이터 분석하기

답글 네트워크 가져오기

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())
Python으로 소셜 미디어 데이터 분석하기

시각화

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

방향 그래프

Python으로 소셜 미디어 데이터 분석하기

시각화 옵션

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')

수정된 방향 그래프

Python으로 소셜 미디어 데이터 분석하기

원형 레이아웃

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')

원형 레이아웃 방향 그래프

Python으로 소셜 미디어 데이터 분석하기

연습해 봅시다!

Python으로 소셜 미디어 데이터 분석하기

Preparing Video For Download...