Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call an element in a numpy array?

This is a really simple question, but I didnt find the answer. How to call an element in an numpy array?

import numpy as np  arr = np.array([[1,2,3,4,5],[6,7,8,9,10]])  print arr(0,0) 

The code above doesn't work.

like image 816
kame Avatar asked Aug 27 '10 08:08

kame


People also ask

How do you access an element of a NumPy array?

You can access an array element by referring to its index number. The indexes in NumPy arrays start with 0, meaning that the first element has index 0, and the second has index 1 etc.

How do you call an element from an array?

To refer to multiple elements of an array, use the colon ':' operator, which allows you to specify a range of elements using the form 'start:end'. The colon alone, without start or end values, specifies all the elements in that dimension.

How do you call an element in an array in Python?

We can access elements of an array using the index operator [] . All you need do in order to access a particular element is to call the array you created. Beside the array is the index [] operator, which will have the value of the particular element's index position from a given array.

How do you access the elements of an array?

To access an individual element of an array, use the name of the array name followed by the index of the element in square brackets. Array indices start at 0 and end at size-1: array_name[index]; accesses the index'th element of array_name starting at zero.


1 Answers

Just use square brackets instead:

print arr[1,1] 
like image 192
carl Avatar answered Sep 21 '22 09:09

carl