Skip to content
Related Articles

Related Articles

Python | Numpy np.coords() method
  • Last Updated : 03 Nov, 2019

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.




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


Output :

(1, )



Example #2 :




# 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)


Output :

(1, 1)

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :