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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。