Numpy: find index of the elements within range

前端 未结 12 2235
盖世英雄少女心
盖世英雄少女心 2020-11-28 23:01

I have a numpy array of numbers, for example,

a = np.array([1, 3, 5, 6, 9, 10, 14, 15, 56])  

I would like to find all the indexes of the

12条回答
  •  北海茫月
    2020-11-28 23:27

    You can use np.clip() to achieve the same:

    a = [1, 3, 5, 6, 9, 10, 14, 15, 56]  
    np.clip(a,6,10)
    

    However, it holds the values less than and greater than 6 and 10 respectively.

提交回复
热议问题