Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Numpy
import numpy as np
## 1. argmax()
a = np.arange(6).reshape(2,3)
print(a)
#[Output]:
#[[0 1 2]
# [3 4 5]]
## argsort() for flattened array
print(np.argmax(a))
#[Output]:
#5
## agrsort() along first axis
print(np.argmax(a, axis=0))
#[Output]:
#array([1, 1, 1], dtype=int64)
## 2. argwhere()
## It is returning the indices of elements which are satisfying the condition.
print(np.argwhere(a>=2))
#[Output]:
#array([[0, 2],
# [1, 0],
# [1, 1],
# [1, 2]], dtype=int64)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.