2

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'>

1 Answer 1

3

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])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.