I have an error with NetworkX which says 'module' has no attribute 'from_pandas_dataframe.'
I have a dataframe called nflroster that is format as:
Index . . . Player Team Year
0 . . . Player1 Team1 2014
1 . . .Player2 Team1 2014
2 . . . Player3 Team2 2014
.
. . . . . . .
So according to the documentation here networkx documentation this following line should work
G = nx.from_pandas_dataframe(nflroster,str, 'Team')
However when I run this in Ipy notebook I run into the error, 'module' object has no attribute 'from_pandas_dataframe'.
I import the following
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
import pandas as pd
from pandas import DataFrame as df
I had the same problem here. This is how I solved it:
Try installing networkx from source instead of installing it through pip.
Source Install Step by Step
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
Notice that this specific function From_Pandas_dataframe will be installed in convert_matrix.py file at the networkx folder.
You probably installed an incorrect version of networkx. You probably should check whether you have 1.10.0 <= see history here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With