numpy.put(数组,索引,p_array,模式=“提高”):用给定的p_array值替换数组的特定元素。数组索引适用于扁平数组。
参数:
array : array_like, target array indices : index of the values to be fetched p_array : array_like, values to be placed in target array mode : [{‘raise’, ‘wrap’, ‘clip’}, optional] mentions how out-of-bound indices will behave raise : [default]raise an error wrap : wrap around clip : clip to the range
# Python Program explaining
# numpy.put()
import numpy as geek
a = geek.arange(5)
geek.put(a, [0, 2], [-44, -55])
print("After put : \n", a)
输出:
After put : [-44, 1, -55, 3, 4]
# Python Program explaining
# numpy.put()
import numpy as geek
a = geek.arange(5)
geek.put(a, 22, -5, mode='clip')
print("After put : \n", a)
输出:
array([ 0, 1, 2, 3, -5])
相关用法
注:本文由纯净天空筛选整理自 numpy.put() in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。