Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Use np.min(array) to get the smallest value across a NumPy array. By default, NumPy reduces the full array to one value; add an axis only when you want a result for each row or column.
Find the smallest value in an array
Import NumPy, create an array, and call np.min():
import numpy as np
arr = np.array([8, 3, 12, -2, 5])
smallest = np.min(arr)
print(smallest) # -2
The equivalent array method is arr.min(). With the default axis=None, NumPy reduces across the whole input and returns one value. See the NumPy minimum documentation.
Get a minimum for each row or column
For a two-dimensional array, omit axis for one global minimum. Set axis=0 to reduce the rows at each column position, or axis=1 to reduce the columns within each row:
matrix = np.array([[8, 3, 12], [4, -2, 5]])
print(np.min(matrix)) # -2
print(np.min(matrix, axis=0)) # [ 4 -2 5]
print(np.min(matrix, axis=1)) # [ 3 -2]
Get the position of the minimum instead
np.argmin(arr) returns an index, not the minimum value. Use it when you need the position, then index the array to retrieve the value:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
arr = np.array([8, 3, 12, -2, 5])
index = np.argmin(arr)
value = arr[index]
print(index) # 3
print(value) # -2
NumPy documents argmin as returning indices of minimum values. Use min or np.min when the requested result is the value itself.
Handle NaNs, infinities, and empty arrays
NaN values
np.min() propagates NaNs: a reduction slice containing a NaN can produce NaN. If the intended behavior is to ignore NaN values, use np.nanmin() instead:
Rank #2
arr = np.array([8.0, np.nan, -2.0])
print(np.min(arr)) # nan
print(np.nanmin(arr)) # -2.0
np.nanmin() ignores NaNs, not infinities. If a slice contains only NaNs, NumPy returns NaN and raises a RuntimeWarning. See the NumPy nanmin documentation.
Positive and negative infinity
NumPy follows IEEE floating-point ordering: positive infinity behaves like a large value and negative infinity like a small one. Therefore, -np.inf can be the minimum. The NaN-ignoring behavior of np.nanmin() does not remove infinities.
Empty arrays
An empty array has no ordinary minimum. If a meaningful candidate value exists for your problem, the initial parameter allows reduction of an empty slice. That initial value also participates in the comparison for nonempty input, so it can become the result if it is smaller than every array value. Use it only when that behavior matches your intended rule. Otherwise, check that the array is nonempty before calling min. Details are in the NumPy 2.0 minimum documentation.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.




