say have 2 lists:
arraya = np.array([3,4,1,2,5,6,8,6,3]) arrayb = np.array([4,2,5,6,1,3,6,5,3]) which represents point in 2d.
i want label list looks like:
listlael = [type1,type2,type1,type2,...] that have same length arraya , arrayb and
type1 if arraya value >= 5 , arrayb value >= 5 type2 if eith arraya or arrayb value < 5 i know can go through both array , there fast , convenient way of doing numpy array?
use numpy.where:
>>> np.where((arraya >= 5) & (arrayb >= 5), 'type1', 'type2') array(['type2', 'type2', 'type2', 'type2', 'type2', 'type2', 'type1', 'type1', 'type2'], dtype='|s5')
Comments
Post a Comment