Reputation: 37
I've 24 arrays in a list and I'd like to crate an array with the maximum of each index.
In other words, I've something like this
list_value = [array([1,2,3]), array([4,5,6]), array([7,8,9]), array([1,5,8]), array([9,4,3])]
In my case, each array has 280000 values.
And I would like create an array like this:
max_value = [array([max(4,4,7,1,9),max(2,5,8,5,4),max(3,6,9,8,3)])]
So I want to finally obtain:
max_value = [9,8,9]
type(max_value) = <type 'numpy.ndarray'>
Upvotes: 2
Views: 57
Reputation: 250931
Convert list_value
to a NumPy array and then apply numpy.ndarray.max
on 0th axis:
>>> arr = np.array(list_value)
>>> arr.max(axis=0)
array([9, 8, 9])
Upvotes: 3