Python | Numpy np.coords() method

With the help of np.coords() method, we can get the coordinates of a next value in iteration using np.coords() method.

Syntax : np.coords()
Return : Return the coordinates of next iterator.

Example #1 :
In this example we can see that by using np.coords() method, we are able to get the coordinates of a next iterator using this method.

filter_none

edit
close

play_arrow

link
brightness_4
code

# import numpy
import numpy as np
  
a = np.array([1, 2, 3])
# using np.coords() method
gfg = a.flat
next(gfg)
print(gfg.coords)

chevron_right


Output :

(1, )



Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# import numpy
import numpy as np
  
a = np.array([[1, 2, 3], [4, 5, 6]])
# using np.coords() method
gfg = a.flat
next(gfg)
next(gfg)
next(gfg)
next(gfg)
print(gfg.coords)

chevron_right


Output :

(1, 1)

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.