numpy.amin () in Python

NumPy | Python Methods and Functions

Parameters —

  • arr: [array_like] input data
  • axis : axis [int or tuples of int] along which we want to get the minimum value. Otherwise, it will assume that arr will be flattened.
  • out: [ndarray, optional] An alternate output array to put the result into
  • keepdmis: [boolean, optional] If this parameter is set to True, the downsized axes remain in
    the result as dimensions with size one. With this option, the result will translate correctly
    the input array. If a default is passed, then keepdims will not be passed to all
    ndarray subclasses, however any non-default will be. If the subclass sum method
    does not implement keepdims, exceptions will be thrown.

Return —

Minimum array — arr [ndarray or scalar], scalar if axis is None; 
The result is an array of dimensions a.ndim — 1 if axis is specified.

Code —

# Python program illustrating
# numpy.amin () method

 

import numpy as geek

 
# 1D array

arr = geek.arange ( 8 )

print ( "arr:" , arr)

print ( " Min of arr: " , geek.amin (arr))

  
# 2D array

arr = geek.arange ( 10 ). reshape ( 2 , 5 )

print ( "arr:" , arr)

 
# Minimum smoothed array

print ( "Min of arr, axis = None:" , geek.amin (arr))

 
# Minimum along the first axis
# axis 0 means vertical

print ( "Min of arr, axis = 0:" , geek.amin (arr, axis = 0 ))

 
# Minimum along the second axis
# axis 1 means horizontal

print ( "Min of arr, axis = 1: " , geek.amin (arr, axis = 1 )) 

Exit —

 arr: [0 1 2 3 4 5 6 7] Min of arr: 0 arr: [[0 1 2 3 4] [5 6 7 8 9]] Min of arr, axis = None: 0 Min of arr, axis = 0: [0 1 2 3 4] Min of arr, axis = 1: [0 5] 

Links —
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.amin.html#numpy.amin

Note —
These codes will not work for online IDs. Please run them on your systems to see how they work

This article is provided by Mohit Gupta_OMG



Get Solution for free from DataCamp guru