Find min value in array > 0

前端 未结 7 1955
夕颜
夕颜 2021-02-07 05:49

I am looking to find the lowest positive value in an array and its position in the list. If a value within the list is duplicated, only the FIRST instance is of interest. This i

7条回答
  •  梦毁少年i
    2021-02-07 06:21

    import numpy as np
    
    x = np.array([1,2,0,5,10])
    x = np.extract(x>0,x)
    min_index = np.amin(x)
    min_value = np.argmin(x)
    

提交回复
热议问题