np.min(arr) and arr.min() are equivalent, both scanning the array for its smallest value; with an axis argument on a multi-dimensional array, it instead returns the minimum along that axis, collapsing it into an array of minimums, one per remaining position. Unlike Python's built-in min(), which works on any iterable of comparable objects, np.min() is specifically optimized for numeric ndarrays and computes at C speed.
1Understanding np.min()
np.min(arr) and arr.min() are equivalent, both scanning the array for its smallest value; with an axis argument on a multi-dimensional array, it instead returns the minimum along that axis, collapsing it into an array of minimums, one per remaining position. Unlike Python's built-in min(), which works on any iterable of comparable objects, np.min() is specifically optimized for numeric ndarrays and computes at C speed.
For multiple arrays combined element-wise, use np.minimum(a, b) instead of np.min() — np.min() finds the smallest value within a single array, or along an axis, while np.minimum() compares two arrays element-wise and keeps the smaller value at each position.
import numpy as np
arr = np.array([5, 2, 8, 1, 9])
print(np.min(arr))2Practical Example
Here is a real-world application of np.min() showing how it is used in production NumPy code.
import numpy as np
a = np.array([1, 5, 3])
b = np.array([4, 2, 6])
print(np.minimum(a, b))3Best Practices
Follow these guidelines when working with np.min():
1. Use np.min()/arr.min() for the overall or per-axis smallest value within one array
2. Use np.minimum(a, b) instead when you need an element-wise comparison between two separate arrays
3. Use np.nanmin() when NaN values in the data should be ignored rather than causing the result to be NaN
Tip: For multiple arrays combined element-wise, use np.minimum(a, b) instead of np.min() — np.min() finds the smallest value within a single array, or along an axis, while np.minimum() compares two arrays element-wise and keeps the smaller value at each position.
import numpy as np
arr = np.array([5, 2, 8, 1, 9])
print(np.min(arr))