python max of list of arrays

前端 未结 4 1628
礼貌的吻别
礼貌的吻别 2021-01-12 10:50

I have a list of arrays like:

a = [array([6,2]),array([8,3]),array([4,2])]

I tried max(a) which returns the following error:

4条回答
  •  醉梦人生
    2021-01-12 11:18

    To have the max array along with the idx, this is what i'm using now:

    a = [array([6,2]),array([8,3]),array([4,2])]
    
    In: max_a = map(max, a)
    Out: max_a = [6,8,4]
    
    In: idx = max_a.index(max(max_a))
    Out: idx = 1
    
    In: result = a[idx]
    Out: reusult = [8,3]
    

提交回复
热议问题