【发布时间】:2019-11-04 19:03:10
【问题描述】:
我有一个数组 x 和一个过滤器列表(布尔数组的长度与 x 相同):
x = np.random.rand(10)
filt1 = x > .2
filt2 = x < .5
filt3 = x % 2 > .02
filters_list = [filt1, filt2, filt3]
我想创建一个过滤器,它是filters_list 中所有过滤器的逻辑与,所以输出应该是
output = x[filt1 & filt2 & filt3]
假设len(filters_list) 是任意的,我如何从filters_list 创建过滤器filt1 & filt2 & filt3?
【问题讨论】:
-
看
np.logical_and
标签: python arrays numpy boolean-logic