查找3Darray满足多种条件的索引位置

2024-05-20 09:39:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个三维数组,每个波段由几个数字组成。是否有函数返回数组满足多个条件的索引位置?

我尝试了以下方法:

index_pos = numpy.where(
    array[:,:,0]==10 and array[:,:,1]==15 and array[:,:,2]==30)

它返回错误:

ValueError: The truth value of an array with more than one element is ambiguous.
Use a.any() or a.all()

Tags: andthe方法函数posnumpyindex波段