python - Most pythonic way to find the maximum elements out of list of np.array? -


i have list of np.array, mya = [a0,...,an] (all of have same shape , dtype). ai has shape ai = array[xi0,xi1,..,xim]. want get

[max((a[i] in mya)) in range(m)] 

. example, let x=np.array([3,4,5]), y=np.array([2,50,-1]) , z=np.array([30,0,3]) mya = [x,y,z], want [30,50,5] (or np.array equivalent).

giving m m=len(mya[0]), code above work, seems way tedious. suggested ways achieve this?

in numpy, numpy.amax(myarray) give maximum of myarray. if maximum of each list/array of first dimmension, can set axis want. in case, should be:

x=np.array([3,4,5]) y=np.array([2,50,-1]) z=np.array([30,0,3]) mya = [x,y,z]  maximum = np.amax(mya, axis=0) # maximum store list [maximumofx, maximumofy, maximumofz] -> [30,50,5] 

see docs


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -