numpy 索引括号内的条件?
condition inside numpy index bracket?
我正在寻找说明可以完成以下操作的 numpy 文档。谁能告诉我应该参考哪里?
image = np.arange(12).reshape((4, 3))
image[image < 10] = 0
>> image
[[ 0 0 0]
[ 0 0 0]
[ 0 0 0]
[ 0 10 11]]
这是布尔数组索引的示例 - http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#boolean-array-indexing
In general if an index includes a Boolean array, the result will be identical to inserting obj.nonzero()
into the same position and using the integer array indexing mechanism
我正在寻找说明可以完成以下操作的 numpy 文档。谁能告诉我应该参考哪里?
image = np.arange(12).reshape((4, 3))
image[image < 10] = 0
>> image
[[ 0 0 0]
[ 0 0 0]
[ 0 0 0]
[ 0 10 11]]
这是布尔数组索引的示例 - http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#boolean-array-indexing
In general if an index includes a Boolean array, the result will be identical to inserting
obj.nonzero()
into the same position and using the integer array indexing mechanism