Are you looking for dual np.where i.e
A = np.array([0,1,2,3,1,-5,-6,-7])
k = np.where(A>0,1,np.where(A<0,0.01,A))
Or you can use np.select
for multiple conditions .
k = np.select([A>0,A<0],[1,.01],A)
Ouptut :
[ 0. 1. 1. 1. 1. 0.01 0.01 0.01]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…