numpy.
select
根据条件返回从选项列表中的元素绘制的数组。
从中确定数组的条件列表 choicelist 取输出元素。当满足多个条件时,在 condlist 使用。
从中获取输出元素的数组列表。它的长度必须与 condlist .
插入的元素 output 当所有条件都评估为假时。
位置m处的输出是中数组的第m个元素 choicelist 其中对应数组的m元素 condlist 是True。
参见
where
根据条件从两个数组之一返回元素。
take
choose
compress
diag
diagonal
实例
>>> x = np.arange(10) >>> condlist = [x<3, x>5] >>> choicelist = [x, x**2] >>> np.select(condlist, choicelist) array([ 0, 1, 2, ..., 49, 64, 81])