Replacing Python negatives with 0 without Conditional operator and Python conditionals

后端 未结 0 1396
Happy的楠姐
Happy的楠姐 2020-11-21 22:24

I want to detect a negative number and replace it with 0

a = np.arange(10)
b=np.where(a<5,a,-1*a)
b[b<0]=0  #conditional operator \'<\' 
b

相关标签:
回答
  • 消灭零回复
提交回复
热议问题