I have been battling with this problem for a little bit now, I know this is very simple - but I have little experience with Python or NetworkX. My question is very simple, I am trying to plot a large dataset (about 200 rows/columns) of a matrix that looks like this. The first row and first column are identical.
A,B,C,D,E,F,G,H,I,J,K
A,0,1,1,0,1,1,1,1,0,1,0
B,1,0,0,0,1,1,1,1,0,1,0
C,1,0,0,0,1,1,1,1,0,1,0
It just a matrix showing how people are connected, and all I want is to import and plot this csv file, with it's corresponding labels in NetworkX.
I have this file (people.cs
v), and looking at previous answers here, it seems the best way to do this is by putting the data in an array with numpy.
There seems to be a problem with this:
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
from numpy import genfromtxt
import numpy as np
mydata = genfromtxt('mouse.csv', delimiter=',')
I get the following output:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/npyio.py", line 1272, in genfromtxt
fhd = iter(np.lib._datasource.open(fname, 'rbU'))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/_datasource.py", line 145, in open
return ds.open(path, mode)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/_datasource.py", line 472, in open
found = self._findfile(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/_datasource.py", line 323, in _findfile
if self.exists(name):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/_datasource.py", line 417, in exists
from urllib2 import urlopen
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 94, in <module>
import httplib
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 69, in <module>
from array import array
File "/Users/Plosslab/Documents/PythonStuff/array.py", line 4, in <module>
NameError: name 'array' is not defined