Python matrix problems -


this continued thread: python matrix, solution?


input

from numpy import * import numpy  x=[['1','7'],  ['1.5', '8'],  ['2', '5.5'],  ['2','9']] 

code

y = x[:, :, none] * x[:, none] print y.sum(axis=0) 

i received error:

"list indices must integers, not tuple"

but if x x = numpy.array([[1, 7], [1.5, 8], [2, 5.5], [2, 9]]) it's ok, don't have such input.

convert x numpy array of numbers:

x = numpy.asanyarray([[float(z) z in y] y in x]) 

Comments

Popular posts from this blog

Python __call__ special method practical example -

How can I edit my VIM config so that Vim treats ".ejs" files the same as it currently treats my html files? -