查找具有两个约束的2D数组的索引
我有两个相等大小的2D数组,并且正在尝试识别满足两个条件的索引。这是我尝试的和我得到的。有什么建议吗?我正在使用np.Where
,这似乎不是正确的选择。
感谢您的帮助。
ind_direct_pos = np.where((bz_2D_surface3 > 0.0) and (jz_2D_surface3 > 0.0))
valueerror:一个以上元素的数组的真实价值是 模糊的。使用a.any()或a.all()
I have two 2D arrays in NumPy of equal size, and am trying to identify the indices where two conditions are met. Here's what I try and what I get. Any suggestions? I'm using np.where
and this does not seem to be the correct choice.
Thanks for any help.
ind_direct_pos = np.where((bz_2D_surface3 > 0.0) and (jz_2D_surface3 > 0.0))
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果两个具有相同大小的数组,而不是相同的形状,则首先可以
ravel
(使用and
而不是&
是此问题的原因,如 iiahdi comment ):如果我们有两个带有的阵列相同的形状:
If the two arrays with the same size, not the same shape, we can
ravel
it at first (usingand
instead&
is a cause of this problem as I'mahdi comment):if we have two arrays with the same shape: