Python has a min() built-in function:
Copy>>> darr = [1, 3.14159, 1e100, -2.71828]
>>> min(darr)
-2.71828
Answer from Greg Hewgill on Stack Overflow Top answer 1 of 4
86
Python has a min() built-in function:
Copy>>> darr = [1, 3.14159, 1e100, -2.71828]
>>> min(darr)
-2.71828
2 of 4
25
If you want to use numpy, you must define darr to be a numpy array, not a list:
Copyimport numpy as np
darr = np.array([1, 3.14159, 1e100, -2.71828])
print(darr.min())
darr.argmin() will give you the index corresponding to the minimum.
The reason you were getting an error is because argmin is a method understood by numpy arrays, but not by Python lists.
Tutorialspoint
tutorialspoint.com › python › list_min.htm
Python List min() Method
Traceback (most recent call last):File "main.py", line 2, in <module>print("min value element : ", str(min(list1)))TypeError: '<' not supported between instances of 'str' and 'int'
Videos
02:13
Max and Min of an array | Python Exercises for Beginners - Exercise ...
04:24
Calculate Max & Min of NumPy Array in Python (Example) | np.max ...
Find Minimum and Maximum Number in Array (Iterative and Recursive) ...
06:09
Find The Minimum Number In A List Without Using min() | Python ...
Max and Min of an array | Python Exercises for Beginners ...
00:53
How To Find Min/Max Value In Numpy Array | Python Tutorial - YouTube
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.min.html
numpy.min — NumPy v2.2 Manual
Minimum of a. If axis is None, the result is a scalar value. If axis is an int, the result is an array of dimension a.ndim - 1.
Codecademy
codecademy.com › docs › python:numpy › built-in functions › .min()
Python:NumPy | Built-in Functions | .min() | Codecademy
June 9, 2025 - This example shows how to find the minimum value of an entire array and along specific axes: ... Machine Learning Data Scientists solve problems at scale, make predictions, find patterns, and more! They use Python, SQL, and algorithms.
Programiz
programiz.com › python-programming › numpy › methods › min
NumPy min()
# pass the 'out' argument to store the result in array2 np.min(array1, axis = 0, out = array2) print(array2) ... When keepdims = True, the dimensions of the resulting array matches the dimension of an input array.
Mimo
mimo.org › glossary › python › min
Python min(): Syntax, Usage, and Examples
Python · Open in Mimo · Open in Mimo · Copy Code · lists = [[3, 4, 1], [8, 2], [9, 0]] min_overall = min(min(lst) for lst in lists) print(min_overall) # Output: 0 · This works well for matrices or nested data structures. When working with numerical data, the numpy module provides its own ...
Python Data Science Handbook
jakevdp.github.io › PythonDataScienceHandbook › 02.04-computation-on-arrays-aggregates.html
Aggregations: Min, Max, and Everything In Between | Python Data Science Handbook
By default, each NumPy aggregation function will return the aggregate over the entire array: ... Aggregation functions take an additional argument specifying the axis along which the aggregate is computed. For example, we can find the minimum value within each column by specifying axis=0:
DataCamp
datacamp.com › doc › numpy › min
NumPy min()
Handle edge cases. Consider scenarios like empty arrays or arrays with `NaN` values. Note that `numpy.min()` will return `NaN` if any `NaN` values are present.
W3Schools
w3schools.com › python › ref_func_min.asp
Python min() Function
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... The min() function returns the item with the lowest value, or the item with the lowest value in an iterable.
NumPy
numpy.org › doc › stable › › reference › generated › numpy.min.html
numpy.min — NumPy v2.4 Manual
Minimum of a. If axis is None, the result is a scalar value. If axis is an int, the result is an array of dimension a.ndim - 1.
NumPy
numpy.org › doc › stable › reference › generated › numpy.minimum.html
numpy.minimum — NumPy v2.4 Manual
Compare two arrays and return a new array containing the element-wise minima. If one of the elements being compared is a NaN, then that element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least ...
HowToDoInJava
howtodoinjava.com › home › python examples › python max() and min(): find max and min in array
Python max() and min(): Find max and min in Array
September 21, 2023 - Rerun the previous example with min() function. prices = { 'how': 45.23, 'to': 612.78, 'do': 205.55, 'in': 37.20, 'java': 10.75 } minKey = min( prices.keys() ) print(minKey) # do minVal = min( prices.values() ) print(minVal) # 10.75 · The max() and min() functions in Python are powerful tools for finding the maximum and minimum values within arrays and other iterable objects.
NumPy
numpy.org › doc › stable › reference › generated › numpy.amin.html
numpy.amin — NumPy v2.4 Manual
January 31, 2021 - Return the minimum of an array or minimum along an axis.
Programiz
programiz.com › python-programming › methods › built-in › min
Python min()
result = min(4, -5, 23, 5) print("The minimum number is:", result) ... If you need to find the largest item, you can use the Python max() function.
TutorialsPoint
tutorialspoint.com › return-the-minimum-of-an-array-or-minimum-ignoring-any-nans-in-python
Return the minimum of an array or minimum ignoring any ...
February 28, 2022 - This function returns a scalar value or a NumPy array containing the minimum values along the specified axis, ignoring NaN values. Following is a basic example of finding the minimum value in an array using the NumPy nanmin() function, while ...