Skip to content
Justice Tech School

argmax along axes

argmax and argmin accept an axis to find positions per row or column.

Example
a = np.array([[1, 9, 3], [8, 2, 7]])
print(a.argmax(axis=1), a.argmin(axis=0))
print(np.unravel_index(a.argmax(), a.shape))

Result

[1 0] [0 1 0]
(np.int64(0), np.int64(1))

Exercise

Per row.

a.argmax(axis=)

Quiz Test

What does unravel_index do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.