[英]calling `numpy.where` on a `masked_array`
Here's an example: 这是一个例子:
import numpy
from numpy import arange, where
from numpy.ma import masked_array
a = masked_array(arange(10), arange(10) < 5)
print(where((a <= 6))[0])
Expected output: 预期产量:
[5, 6]
Actual output: 实际输出:
[0, 1, 2, 3, 4, 5, 6]
How can I achieve the expected output? 如何获得预期的输出? Thanks!
谢谢! :)
:)
您只需要使用“ numpy.ma.where”即可处理屏蔽的数组:
print(numpy.ma.where((a <= 6))[0])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.