在numpy中查找3d数组中的2d数组的索引

时间:2018-04-01 08:10:23

标签: python arrays numpy

我想在3d数组中找到一个二维数组。为了在2d数组中找到1d数组,我可以使用np.where(np.all(a==b, axis=1))[0][0]

>>> import numpy as np
>>>
>>> a = np.array([[[1, 0, 0],
                   [0, 0, 0],
                   [0, 0, 0]],

                  [[0, 0, 0],
                   [0, 0, 0],
                   [0, 0, 0]]])
>>>
>>> b = np.array([[1, 0, 0],
                  [0, 0, 0],
                  [0, 0, 0]])
>>>
>>> a.find(b)
0

1 个答案:

答案 0 :(得分:3)

$app->bind('path.public', function() { return __DIR__; }); 关键字接受元组,因此您只需执行以下操作:

axis
相关问题