Starting with this:
Mur = np.array([200,246,372])*3*5
Mumax = np.array([1400,600,700])*3*5
Mu = np.array([100,500,2000])*3*5
Acreq = np.where(Mu<Mur,0,"zero")
Acreq = np.where((Mur<Mu)&(Mu<Mumax),45,Acreq)
Acreq = np.where(Mu>Mumax,60,Acreq)
print(Acreq)
['0' '45' '60']
Try this:
conditions = [Mu<Mur, (Mur<Mu)&(Mu<Mumax), Mu>Mumax ]
choices = [ 0, 45, 60 ]
Acreq = np.select(conditions, choices, default='zero')
print(Acreq)
['0' '45' '60']
This also works:
np.where((Mur<Mu)&(Mu<Mumax),45,np.where(Mu>Mumax,60,np.where(Mu<Mur,0,"zero")))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…