Is possible to construct a NumPy array from a python list?
import numpy as np
... ## other code
some list comprehension
t=[nodel[ nodenext[i][j] ] for j in idx]
#for each link, find the node lables
#t is the list of node labels
Convert the list to a numpy array using the array method specified in the numpy library.
t=np.array(t)
This may be helpful: https://numpy.org/devdocs/user/basics.creation.html
Yes it is:
a = numpy.array([1,2,3])
Here is a more complete example:
import csv
import numpy as np
with open('filename','rb') as csvfile:
cdl = list( csv.reader(csvfile,delimiter='\t'))
print "Number of records = " + str(len(cdl))
#then later
npcdl = np.array(cdl)
Hope this helps!!