我有一个np.array像
x = np.array([[1,2], [4,5], [4,6], [5,4], [4,5]])
现在我想要 x 等于[4,5]( -> [1, 4]) 的索引。操作员==以不同的方式工作:
x == [4,5]
array([[False, False],
[ True, True],
[ True, False],
[False, False],
[ True, True]], dtype=bool)
但我想要类似的东西[False, True, False, False, True]。可以做and吗?
通常数组非常大,我必须做很多次,所以我需要一个非常快速的方法。