python - Get a value in a numpy array from a index in a variable -


i trying access value in multi dimensional numpy array. can done when know everything, exemple :

t = numpy.arrange(9).reshape(3, 3) t[2, 2]

and returns 8, want. now, let's assume [2, 2] stored in index variable. how can take value in t index stored in index ? t[index] returns last row twice (pretty logical not want).

thank !

try

ind=tuple(2,2) x[ind] 

x[2,2] same x[(2,2)] translated method call: x.__getitem__((2,2)).

some numpy functions build index list or array, convert tuple use in index.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -