Nhập và trực quan hóa mạng Twitter

Phân tích dữ liệu mạng xã hội bằng Python

Alex Hanna

Computational Social Scientist

Danh sách cạnh

         BethMohn           ChristianMohn
           ASilNY         LarrySchweikart
         mattg444              WhiteHouse
    hlthiskrieger                aravosis
          Herky86          SenJeffMerkley
  PatrickParsons9              TwitterGov
    New_Narrative                 CFR_org
           dddlor               roywoodjr
      scrivener50          michaelscherer
  ChiefsHeadCoach           johnpavlovitz
Phân tích dữ liệu mạng xã hội bằng Python

Nhập mạng retweet

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())
Phân tích dữ liệu mạng xã hội bằng Python

Nhập mạng quote

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())
Phân tích dữ liệu mạng xã hội bằng Python

Nhập mạng trả lời

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())
Phân tích dữ liệu mạng xã hội bằng Python

Trực quan hóa

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

Đồ thị có hướng

Phân tích dữ liệu mạng xã hội bằng Python

Tùy chọn trực quan hóa

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

Đồ thị có hướng đã chỉnh

Phân tích dữ liệu mạng xã hội bằng Python

Bố cục hình tròn

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

Bố cục tròn cho đồ thị có hướng

Phân tích dữ liệu mạng xã hội bằng Python

Cùng luyện tập nào!

Phân tích dữ liệu mạng xã hội bằng Python

Preparing Video For Download...