Is there a function in the numpy API that finds both max and min with only a single pass through the data?

No. At the time of this writing, there is no such function. (And yes, if there were such a function, its performance would be significantly better than calling numpy.amin() and numpy.amax() successively on a large array.)

Answer from Stuart Berg on Stack Overflow
๐ŸŒ
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
In particular, their optional arguments have different meanings, and np.sum is aware of multiple array dimensions, as we will see in the following section. Similarly, Python has built-in min and max functions, used to find the minimum value and maximum value of any given array:
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ find-the-maximum-and-minimum-element-in-a-numpy-array
Find the maximum and minimum element in a NumPy array - GeeksforGeeks
August 13, 2021 - For finding the minimum element use numpy.min("array name") function. ... # import numpy library import numpy # creating a numpy array of integers arr = numpy.array([1, 5, 4, 8, 3, 7]) # finding the maximum and # minimum element in the array ...
๐ŸŒ
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. If axis is a tuple, the result is an array of dimension a.ndim - len(axis). ... The maximum value of an array along a given axis, propagating any NaNs.
๐ŸŒ
Linux Hint
linuxhint.com โ€บ use-python-numpy-mean-min-max-functions
How to use Python NumPy mean(), min() and max() functions? โ€“ Linux Hint
If the particular axis is mentioned in the function, then it will calculate the mean value of the particular axis. max() function is used to find out the maximum value from the array elements or the elements of the particular array axis. min() function is used to find out the minimum value ...
๐ŸŒ
Pythontic
pythontic.com โ€บ numpy โ€บ ndarray โ€บ min_max
The min() and max() functions of ndarray | Pythontic.com
min() and max() functions of numpy.ndarray() provides the minimum and maximum values along the specified axis. An example with a 3-dimensional array is provided.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.2 โ€บ reference โ€บ generated โ€บ numpy.max.html
numpy.max โ€” NumPy v2.2 Manual
Maximum 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. If axis is a tuple, the result is an array of dimension a.ndim - len(axis). ... The minimum value of an array along a given axis, propagating any NaNs.
๐ŸŒ
PyPI
pypi.org โ€บ project โ€บ numpy-minmax
numpy-minmax ยท PyPI
A fast python library for finding both min and max value in a NumPy array
      ยป pip install numpy-minmax
    
Published ย  Jun 28, 2025
Version ย  0.5.0
Find elsewhere
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python โ€บ numpy
NumPy: Sum, mean, max, min for entire array, column/row-wise | note.nkmk.me
January 20, 2024 - NumPy allows you to calculate the sum, average, maximum, and minimum of an array (ndarray) using functions such as np.sum(), np.mean(), np.max(), and np.min(). These functions allow you to specify the axis argument to obtain results for each ...
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python โ€บ numpy
NumPy: clip() to limit array values to min and max | note.nkmk.me
February 1, 2024 - l = list(range(10)) print(l) # ... ... In the clip() method of ndarray, the first argument min is for the minimum value and the second argument max for the maximum value....
๐ŸŒ
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. If axis is a tuple, the result is an array of dimension a.ndim - len(axis). ... The maximum value of an array along a given axis, propagating any NaNs.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-find-the-maximum-and-minimum-value-in-numpy-1d-array
How to find the maximum and minimum value in NumPy 1d-array? - GeeksforGeeks
July 15, 2025 - # import library import numpy as np # create a numpy 1d-array array = np.array([1, 2, 3, 0, -1, -2]) # find max element in an array max_ele = np.amax(array) # find min element in an array min_ele = np.amin(array) # show the outputs print("Given Array:", array) print("Max Element:", max_ele) print("Min Element:", min_ele) ... Method 2: Using numpy.argmax() and numpy.argmin() function of NumPy library.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ find-the-maximum-and-minimum-element-in-a-numpy-array
Find the maximum and minimum element in a NumPy array
August 23, 2023 - The calculation of the maximum value in a dataset is simple and easy. The function scans through all the elements in the array and identifies the largest value. This process can be applied to arrays of any shape or size. Let us understand this concept with an example โˆ’ ยท import numpy as np data = np.array([3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) # Calculating the maximum value max_value = np.max(data) print("Maximum value:", max_value)
๐ŸŒ
Leyaa
leyaa.ai โ€บ home โ€บ how to use min and max functions in numpy for data analysis
How to Use min and max Functions in NumPy for Data Analysis | Leyaa.ai
4 weeks ago - These functions can operate on the entire array or along a specific axis to get min or max values per row or column. ... import numpy as np # Find min and max of entire array np.min(array) np.max(array) # Find min and max along rows (axis=1) or columns (axis=0) np.min(array, axis=1) np.max(array, axis=0)
๐ŸŒ
Real Python
realpython.com โ€บ numpy-max-maximum
NumPy's max() and maximum(): Find Extreme Values in Arrays โ€“ Real Python
January 18, 2025 - In this introduction to NumPy, you'll learn how to find extreme values using the max() and maximum() functions. This includes finding the maximum element in an array or along a given axis of an array, as well as comparing two arrays to find the larger element in each index position.
๐ŸŒ
ProjectPro
projectpro.io โ€บ recipes โ€บ compute-min-by-max-for-each-row-for-numpy-array-2d
How to compute the min-by-max for each row for a numpy array 2d? -
June 20, 2022 - How to compute the min-by-max for each row for a numpy array 2d? We can find the minimum and maximum values from the each row of a 2D numpy array by using the "min" and "max" functions available in the Numpy library.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.2 โ€บ reference โ€บ generated โ€บ numpy.minimum.html
numpy.minimum โ€” NumPy v2.2 Manual
The minimum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars. ... Element-wise maximum of two arrays, propagates NaNs.
๐ŸŒ
Codegive
codegive.com โ€บ blog โ€บ numpy_min_and_max.php
Numpy min and max
NumPy's implementations of min and max are highly optimized (often using SIMD instructions and parallel processing under the hood). For large arrays, these operations are significantly faster than writing your own min/max logic using Python loops. The difference between np.min(array) and array.min() is generally negligible in terms of performance, as they usually call the same underlying C implementation.