pandas के साथ नेटवर्क डेटा को दर्शाना

इंटरमीडिएट Network Analysis in Python

Eric Ma

Data Carpentry instructor and author of nxviz package

नेटवर्क डेटा स्टोरेज के लिए CSV फ़ाइलें

  • CSV फ़ाइल
person,party,weight
Barrett.Samuel,LondonEnemies,1
Barrett.Samuel,StAndrewsLodge,1
Marshall.Thomas,LondonEnemies,1
Eaton.Joseph,TeaParty,1
Bass.Henry,LondonEnemies,1
इंटरमीडिएट Network Analysis in Python

नेटवर्क डेटा स्टोरेज के लिए CSV फ़ाइलें

  • फायदे:
    • मानव-पठनीय
    • pandas के साथ आगे विश्लेषण करें
  • नुकसान:
    • दोहराव; डिस्क स्पेस
  • दो DataFrames: नोड और एज सूचियाँ
इंटरमीडिएट Network Analysis in Python

नोड सूची और एज सूची

  • नोड सूची
    • हर पंक्ति एक नोड है
    • कॉलम उस नोड से जुड़ा मेटाडेटा दिखाते हैं
  • एज सूची
    • हर पंक्ति एक एज है
    • कॉलम उस एज से जुड़ा मेटाडेटा दिखाते हैं
इंटरमीडिएट Network Analysis in Python

Pandas और ग्राफ़

list(G.nodes(data=True))
[(0, {'bipartite': 0}),
(1, {'bipartite': 0}),
(2, {'bipartite': 0}),
...]
nodelist = []

for n, d in G.nodes(data=True): node_data = dict() node_data['node'] = n
node_data.update(d)
nodelist.append(node_data)
इंटरमीडिएट Network Analysis in Python

Pandas और ग्राफ़

nodelist
[{'bipartite': 0, 'node': 0},
{'bipartite': 0, 'node': 1},
{'bipartite': 0, 'node': 2},
{'bipartite': 0, 'node': 3},
{'bipartite': 0, 'node': 4},...]
इंटरमीडिएट Network Analysis in Python

Pandas और ग्राफ़

import pandas as pd
pd.DataFrame(nodelist)
  bipartite  node
0           0     0
1           0     1
2           0     2
3           0     3
4           0     4
5           1     5
6           1     6
7           1     7
pd.DataFrame(nodelist).to_csv('my_file.csv')
इंटरमीडिएट Network Analysis in Python

अभ्यास करते हैं!

इंटरमीडिएट Network Analysis in Python

Preparing Video For Download...