Python | The numpy np.coords () method



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

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

Example # 1:
In this example we see that with np.coords () we can get the coordinates next iterator using this method.

# NumPy import

import numpy as np

 

a = np.array ([ 1 , 2 , 3 ])

# using the np.coords () method

gfg = a.flat

next (gfg)

print (gfg.coords)

Output:

(1,)

Example # 2:

# NumPy import

import numpy as np

 

a = np.array ([[ 1 , 2 < code class = "plain">, 3 ], [ 4 , 5 , 6 ]])

# using the np.coords () method

gfg = a.flat

next (gfg)

next (gfg)

next (gfg)

next (gfg)

print (gfg.coords)

Output:

(1, 1)