将低值设置为数组中的零

时间:2017-03-22 20:26:20

标签: python arrays numpy

我有以下数组列表:

[array([  2.64161017e+00,   0.00000000e+00,  -1.61751972e-16]), array([ 0.,  0.,  0.]), array([ -5.84525493e-01,   1.68725948e+00,   3.57918637e-17]), array([  3.25845641e+00,  -1.96333607e+00,  -1.99522910e-16]), array([ 3.42568843,  0.92118282,  1.67971424]), array([ 3.4257338 ,  0.92122015, -1.67966083])]

我试图用零替换所有小值:

Tab[np.abs(Tab)<0.0000001] = 0

但是,我解决此问题的方法失败了,我收到了错误:

TypeError: only integer arrays with one element can be converted to an index

如果元素低于特定阈值,如何将元素设置为零?

0 个答案:

没有答案