【发布时间】:2021-03-14 16:28:36
【问题描述】:
我有 a = np.arange(21).reshape(7,3) 和 b = np.array([[3,4,5], [9,10,11]]) 的数组
a = [[ 0 1 2]
[ 3 4 5]
[ 6 7 8]
[ 9 10 11]
[12 13 14]
[15 16 17]
[18 19 20]]
b = [[3 4 5]
[9 10 11]]
我想在 a 中找到 b 的行号。因此,我希望将 1 和 3 作为我的 输出。我知道要查找索引,我可以使用np.where() 或np.argwhere()。但是,我不知道我们是否可以使用它们来解决这个问题,或者我必须使用其他功能。我试过c = np.argwhere(a == b),但它给出了错误。
【问题讨论】:
标签: python python-3.x numpy indexing