I have three lists that I want to convert into one list. When I try the following a get this error
A = numpy.array(X,Y,Z,dtype=float)
ValueError: only 2 non-keyword arguments accepted
I did not see anything here that says you can only give it two arguments
http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html
Here is the code
import numpy
from numpy import *
X = []
Y = []
Z = []
f = open(r'C:\My.txt')
f.readline()
for line in f:
if line != '':
line = line.strip()
columns = line.split()
x = columns[2]
y = columns[3]
z = columns[4]
X.append(x)
Y.append(y) #appends data in list
Z.append(z)
A = numpy.array(X,Y,Z,dtype=float)
A.shape(3,3)
print(A)
Thanks in advanceh
Try passing your three lists as a tuple:
In the
numpy.arraydocumentation the signature fornumpy.arrayisi.e. the single argument
objectis what gets turned into an ndarray, every other argument must be a keyword argument (hence the error message which you were getting) which can be used to customise the creation of the array.Edit In respone to Surfcast23’s comment, in the IDE I tried the following: