.amin()
THE-Spellchecker154 total contributions
Published Jun 1, 2023Updated May 15, 2024
Contribute to Docs
The .amin()
function returns the minimum of an array or minimum along an axis. The .amin()
function is equivalent to ndarray.min()
.
Syntax
numpy.amin(a, axis, out, keepdims, initial, where)
The a
parameter is required and represents the array of elements to choose the minimum from. All other parameters are optional.
Parameters of the .amin()
function:
a
: The array of elements to choose the minimum from.axis
: An int or a tuple of ints specifying the axis/axes along which to choose the minimum. By default it is set asaxis=None
.out
: Anndarray
to receive result. Must have the same shape as expected output.keepdims
: A boolean; ifTrue
will keep reduced axes in the result as dimensions with size one.initial
: The maximum value of an output element.where
: A boolean array that maps toarray
and selects which elements to compare for the minimum.
Returns:
- If axis is None, the result would be a scalar value of the minimum element of the array.
- If axis is an integer, the result would be an array of dimension
a.ndim - 1
. - If axis is a tuple, the result would be an array of dimension
a.ndim - len(axis)
.
Example
The following example creates an array then uses a few .amin()
operations to return the minimum.
import numpy as npnd = np.array([[1,2,3],[4,5,6]])print(np.amin(nd))print(np.amin(nd, axis=0))print(np.amin(nd, axis=1))
This produces the following output:
1[1 2 3][1 4]
Codebyte Example
The following example creates an array then uses a few .amin()
operations with various arguments to return the minimum.
All contributors
- THE-Spellchecker154 total contributions
- byte85960953741 total contribution
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.