data = np.array([1, 4, 5, 5, 6, 8, 8, 9])
values = [2, 3, 4, 6, 7]
print(np.in1d(values, data))
index = np.searchsorted(data, values)
print(data[index] == values)
What is the most efficient way to check if a value exists in a NumPy array?