本文共 198 字,大约阅读时间需要 1 分钟。
np.where类似于条件表达式,如果条件满足,返回第一个值,反之返回第二个值。
>>> import numpy as np>>> a=np.arange(10)>>> aarray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])>>> np.where(a<6,a,10*a)array([ 0, 1, 2, 3, 4, 5, 60, 70, 80, 90])>>>
转载地址:http://koja.baihongyu.com/