且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从多维数组返回最大值?

更新时间:2021-09-14 09:12:49

自从您在评论中提到您正在使用numpy ...

Since you mentioned in a comment that you are using numpy ...

>>> import numpy as np
>>> a = np.random.rand(3,3)
>>> a
array([[ 0.43852835,  0.07928864,  0.33829191],
       [ 0.60776121,  0.02688291,  0.67274362],
       [ 0.2188034 ,  0.58202254,  0.44704166]])
>>> a.max(axis=1)
array([ 0.43852835,  0.67274362,  0.58202254])


编辑:该文档为这里


edit: the documentation is here