Numpy int array: Find indices of multiple target ints

后端 未结 3 473
孤独总比滥情好
孤独总比滥情好 2021-01-18 07:46

I have a large numpy array (dtype=int) and a set of numbers which I\'d like to find in that array, e.g.,

import numpy as np
values = np.array(         


        
3条回答
  •  粉色の甜心
    2021-01-18 08:30

    Is this fast enough?

    >>> np.where(np.in1d(values, searchvals))
    (array([ 0,  2,  3,  8, 10]),)
    

提交回复
热议问题