如何使用 colab 从数据集创建网络图?
How to create a network graph from a dataset using colab?
我成功上传了我的数据集的边缘文件,但我该如何创建网络图?
这里是networkx
:
import networkx as nx
import pandas as pd
# note that your file doesn't have column names
# passing `names` to label the columns
df = pd.read_csv('file.csv', names=['a','b'])
# don't worry about `source` and `target`
G = nx.from_pandas_edgelist(df, source='a', target='b')
那么G
就是一个双向图实例
我成功上传了我的数据集的边缘文件,但我该如何创建网络图?
这里是networkx
:
import networkx as nx
import pandas as pd
# note that your file doesn't have column names
# passing `names` to label the columns
df = pd.read_csv('file.csv', names=['a','b'])
# don't worry about `source` and `target`
G = nx.from_pandas_edgelist(df, source='a', target='b')
那么G
就是一个双向图实例