python – NetworkX From_Pandas_dataframe
发布时间:2020-12-20 11:42:43 所属栏目:Python 来源:网络整理
导读:我对NetworkX有一个错误,说’模块’没有属性’from_pandas_dataframe’. 我有一个名为nflroster的数据框格式为: Index . . . Player Team Year0 . . . Player1 Team1 20141 . . .Player2 Team1 20142 . . . Player3 Team2 2014.. . . . . . . 所以根据这里
我对NetworkX有一个错误,说’模块’没有属性’from_pandas_dataframe’.
我有一个名为nflroster的数据框格式为: Index . . . Player Team Year 0 . . . Player1 Team1 2014 1 . . .Player2 Team1 2014 2 . . . Player3 Team2 2014 . . . . . . . . 所以根据这里的文档networkx documentation,以下这一行应该有效 G = nx.from_pandas_dataframe(nflroster,str,'Team') 但是,当我在Ipy笔记本中运行时遇到错误,’module’对象没有属性’from_pandas_dataframe’. 我导入以下内容 import numpy as np import networkx as nx import matplotlib.pyplot as plt import pandas as pd from pandas import DataFrame as df 解决方法
我在这里遇到了同样的问题.这就是我解决它的方式:
尝试从源代码安装networkx,而不是通过pip安装. 源安装步骤 Download the source (tar.gz or zip file) from https://pypi.python.org/pypi/networkx/ or get the latest development version from https://github.com/networkx/networkx/ Unpack and change directory to the source directory (it should have the files README.txt and setup.py). Run python setup.py install to build and install 请注意,此特定函数From_Pandas_dataframe将安装在networkx文件夹的convert_matrix.py文件中. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |