numpy.argmin() in Python

The Python numpy.argmin() function returns the indices of minimum elements along the specific axis inside the array.

Basic Syntax

Following is the basic syntax for numpy.argmin() function in Python:

numpy.argmin(arr, axis=None, out=None)

And the parameters are:

ParameterDescription
arrThe input array
axis[int, OPTIONAL] Along the axis like 1 or 0.
out[array, OPTIONAL] If provided then it will insert output to the out array with appropriate shape.

 

Return Value

This function returns array of indices into the array.

Example’s

Following are the examples for numpy.argmin() function:

Example 1

The output for the above program is as given below:

The input array: [
[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14]]
The min element: 0
The indices of minimum element axis = 0: [0, 0, 0, 0, 0]
The indices of minimum element axis = 1: [0, 0, 0]

Example 2

The output for the above program is as given below:

The input array:
[[ 0, 1, 17, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19]]
The min element: 0
The indices of minimum element axis = 0: [0, 0, 1, 0, 0]
The indices of minimum element axix = 1: [0, 0, 0, 0]

LEAVE A REPLY

Please enter your comment!
Please enter your name here