Numpy.amin() method **“returns the minimum of an array or minimum along the axis(if mentioned).”**

**Syntax**

```
numpy.amin(arr, axis=None, out=None, keepdims=<no value>, initial=<no value>)
```

**Parameters**

Numpy amin() function takes up to 4 arguments:

**arr -> This is the array from which we can find the min value****axis**-> This indicates where we want to find the smallest element. Otherwise, it will consider the array flattened. In this case, if we provide axis=0, it returns an array containing the smallest element for each column. If axis=1, it returns an array containing the smallest element from each row.**out -> This is an optional field. This indicates an alternative output array in which the result is placed.****keepdims**-> This is an optional field. If this is set to**True**, the reduced axis is left as dimensions with size one. With this option, the result will broadcast correctly against an input array. If a default value is passed,**keepdims**will not be passed through to all methods of sub-classes of ndarray; however, any non-default value will be. Any exceptions will be raised if the sub-classes sum method does not implement keepdims.

**Return Value**

The np.amin() method returns the minimum of an array of two types.

- Scaler -> If the axis is mentioned, None.
- Array -> Of dimension arr.ndim-1 if the axis is mentioned.

**Example 1: How does the np.amin() method work**

```
import numpy as np
# We will create an 1D array
arr = np.array([47, 20, 41, 63, 21, 4, 74])
# Printing the array
print("The array is: ", arr)
# Shape of the array
print("Shape of the array is : ", np.shape(arr))
# Now we will print min value of this array
print("Minimum value of the given array is: ", np.amin(arr))
```

**Output**

```
The array is: [47 20 41 63 21 4 74]
Shape of the array is : (7,)
Minimum value of the given array is: 4
```

**Example 2: How to Use np.amin() method**

```
#Importing numpy
import numpy as np
# We will create a 2D array
# Of shape 4x3
arr = np.array([(14, 2, 34), (41, 5, 46), (71, 38, 29), (50, 57, 52)])
# Printing the array
print("The array is: ")
print(arr)
print("Shape of the array is: ", np.shape(arr))
# Now we will find the minimun value for some cases
# Minimum value of the whole array
print("Minimum value of the whole array is: ", np.amin(arr))
# Minimum value of each row
a = np.amin(arr, axis=1)
print("Minimum value of each row of the array is: ", a)
# Minimum value of each column
b = np.amin(arr, axis=0)
print("Minimum value of each column of the array is: ", b)
```

**Output**

```
The array is:
[[14 2 34]
[41 5 46]
[71 38 29]
[50 57 52]]
Shape of the array is: (4, 3)
Minimum value of the whole array is: 2
Minimum value of each row of the array is: [ 2 5 29 50]
Minimum value of each column of the array is: [14 2 29]
```

That’s it.

Ankit Lathiya is a Master of Computer Application by education and Android and Laravel Developer by profession and one of the authors of this blog. He is also expert in JavaScript and Python development.