0

Given an nth place in a 2D static numpy array, how should I calculate that point's position within said array? For an example, given the number 5 representing an nth place, and an array shape of (4, 2), I want to receive the position in the array where that nth place is located, which is position (0, 1). 5th place in an array shape of 10, 1 corresponds to position (5, 0) and so on.

Is there a numpy function that I can use?

ZeroMaxinumXZ
  • 357
  • 2
  • 6
  • 21

1 Answers1

-1

Not clear what you mean, try numpy.argwhere(...).

From numpy docs:


    >>> x = np.arange(6).reshape(2,3)
    >>> x
    array([[0, 1, 2],
           [3, 4, 5]])
    >>> np.argwhere(x>1)
    array([[0, 2],
           [1, 0],
           [1, 1],
           [1, 2]])