【python】numpy array特殊数据统一处理

array中的某些数据坏掉,想要统一处理,找到了这个方法,做个笔记。

比如,把数组中所有小于0的数字置为0

import numpy as np

t = np.array([-2, -1, 0, 1, 2])
t[t<0]=0

输出结果为

  [0,0,0,1,2]

 

posted @ 2015-11-10 21:40  料峭  Views(615)  Comments(0Edit  收藏  举报