我有一个数组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
?你知道吗
可以将^{} 与轴和筛选器列表一起使用。你知道吗
相关问题 更多 >
编程相关推荐