Numpy中clip函数的使用

import numpy as np
x=np.array([1,2,3,4,5,6,7,8,9])
np.clip(x,4,6)
Out[88]:
array([4, 4, 4, 4, 5, 6, 6, 6, 6])

numpy.clip(a, a_min, a_max, out=None)

其实就是把数组a的元素限制到[a_min, a_max]区间内

posted @ 2020-02-26 11:05  Z_Agent  阅读(518)  评论(0编辑  收藏  举报