如何在 numpy 数组中搜索一小组值(未排序,不应更改)?它应该返回这些值的索引。
例如:
a = np.array(['d', 'v', 'h', 'r', 'm', 'a']) # in general it will be large
query = np.array(['a', 'v', 'd'])
# Required:
idnx = someNumpyFunction(a, query)
print(indx) # should be [5, 1, 0]
Run Code Online (Sandbox Code Playgroud)
我是 numpy 的初学者,我找不到同时为多个值执行此任务的正确方法(我知道 np.where(a=='d') 可以执行单个值搜索) .