【发布时间】:2018-08-19 18:06:39
【问题描述】:
我有networkx v. 2.1。为了使其与 pandas 数据框一起工作,我尝试了以下操作:
- 通过
pip3安装,这不起作用生成Atrribute Error,如标题,因此被卸载。 - 用“
python3 setup.py install”重新安装
错误描述。
AttributeError: 模块 'networkx' 没有属性 'from_pandas_dataframe`
重现错误的步骤:
我使用csv 导入数据。我这样做是因为我只想从数据集中读取 5000 行。
x=pd.DataFrame([x for x in rawData[:5000]])
x[:10]
0 1 2
0 228055 231908 1
1 228056 228899 1
2 228050 230029 1
3 228059 230564 1
4 228059 230548 1
5 70175 70227 1
6 89370 236886 1
7 89371 247658 1
8 89371 249558 1
9 89371 175997 1
g_data=G=nx.from_pandas_dataframe(x)
module 'networkx' has no attribute 'from_pandas_dataframe'
我知道我错过了from_pandas_dataframe,但找不到安装它的方法。
[m for m in nx.__dir__() if 'pandas' in m]
['from_pandas_adjacency',
'to_pandas_adjacency',
'from_pandas_edgelist',
'to_pandas_edgelist']
【问题讨论】: