With this setup:
>>> A = np.array([0,1,2])
>>> B = np.array([1,0,3])
>>> C = np.array([3,0,4])
You can either do:
>>> np.maximum.reduce([A,B,C])
array([3, 1, 4])
Or:
>>> np.vstack([A,B,C]).max(axis=0)
array([3, 1, 4])
I would go with the first option.
Answer from Daniel on Stack OverflowNumPy
numpy.org โบ doc โบ 2.4 โบ reference โบ generated โบ numpy.maximum.html
numpy.maximum โ NumPy v2.4 Manual
Element-wise maximum of two arrays, ignores NaNs.
NumPy
numpy.org โบ devdocs โบ reference โบ generated โบ numpy.maximum.html
numpy.maximum โ NumPy v2.6.dev0 Manual
Element-wise maximum of two arrays, ignores NaNs.
02:25
Python Numpy Max Function - YouTube
03:11
NumPy argmax() Tutorial: Find Index of Maximum Value in Arrays ...
03:39
NumPy np.max() Tutorial: Find Maximum Values in Arrays | Python ...
04:24
Calculate Max & Min of NumPy Array in Python (Example) | np.max ...
numpy maximum of array
NumPy
numpy.org โบ doc โบ 2.3 โบ reference โบ generated โบ numpy.max.html
numpy.max โ NumPy v2.3 Manual
The maximum value of an array along a given axis, ignoring any NaNs.
Top answer 1 of 3
69
With this setup:
>>> A = np.array([0,1,2])
>>> B = np.array([1,0,3])
>>> C = np.array([3,0,4])
You can either do:
>>> np.maximum.reduce([A,B,C])
array([3, 1, 4])
Or:
>>> np.vstack([A,B,C]).max(axis=0)
array([3, 1, 4])
I would go with the first option.
2 of 3
22
You can use reduce. It repeatedly applies a binary function to a list of values...
For A, B and C given in question...
np.maximum.reduce([A,B,C])
array([3,1,4])
It first computes the np.maximum of A and B and then computes the np.maximum of (np.maximum of A and B) and C.
NumPy
numpy.org โบ doc โบ 2.3 โบ reference โบ generated โบ numpy.maximum.html
numpy.maximum โ NumPy v2.3 Manual
Element-wise maximum of two arrays, ignores NaNs.
DataCamp
datacamp.com โบ doc โบ numpy โบ max
NumPy max()
The `max()` function is used to compute the maximum value of elements in a NumPy array either globally or along a specific axis.
NumPy
numpy.org โบ doc โบ 2.1 โบ reference โบ generated โบ numpy.maximum.html
numpy.maximum โ NumPy v2.1 Manual
Element-wise maximum of two arrays, ignores NaNs.
Programiz
programiz.com โบ python-programming โบ numpy โบ methods โบ maximum
NumPy maximum() (With Examples)
Numpy Broadcasting ยท The maximum() function is used to find the maximum value between the corresponding elements of two arrays.
NumPy
numpy.org โบ doc โบ 2.2 โบ reference โบ generated โบ numpy.maximum.html
numpy.maximum โ NumPy v2.2 Manual
Element-wise maximum of two arrays, ignores NaNs.
JAX Documentation
docs.jax.dev โบ en โบ latest โบ _autosummary โบ jax.numpy.maximum.html
jax.numpy.maximum โ JAX documentation
An array containing the element-wise maximum of x and y.
NumPy
numpy.org โบ devdocs โบ reference โบ generated โบ numpy.max.html
numpy.max โ NumPy v2.6.dev0 Manual
The maximum value of an array along a given axis, ignoring any NaNs.
NumPy
numpy.org โบ doc โบ stable โบ reference โบ generated โบ numpy.maximum.html
numpy.maximum โ NumPy v2.5 Manual
Element-wise maximum of two arrays, ignores NaNs.
NumPy
numpy.org โบ doc โบ 2.2 โบ reference โบ generated โบ numpy.max.html
numpy.max โ NumPy v2.2 Manual
The maximum value of an array along a given axis, ignoring any NaNs.
Top answer 1 of 2
84
numpy.maximum.accumulate works for me.
>>> import numpy
>>> numpy.maximum.accumulate(numpy.array([11,12,13,20,19,18,17,18,23,21]))
array([11, 12, 13, 20, 20, 20, 20, 20, 23, 23])
2 of 2
3
As suggested, there is scipy.maximum.accumulate:
In [9]: x
Out[9]: [1, 3, 2, 5, 4]
In [10]: scipy.maximum.accumulate(x)
Out[10]: array([1, 3, 3, 5, 5])
Codecademy
codecademy.com โบ docs โบ python:numpy โบ built-in functions โบ .max()
Python:NumPy | Built-in Functions | .max() | Codecademy
July 2, 2025 - Returns the maximum value of an array or maximum values along a specified axis.
LinkedIn
linkedin.com โบ posts โบ realpython-com_numpys-max-and-maximum-find-extreme-activity-7238199410856235008-c3gI
NumPy's max() and maximum values for Arrays
Login to LinkedIn to keep in touch with people you know, share ideas, and build your career.