numpy中的put,putmask, place的用法

本文详细介绍了numpy中的put, putmask和place函数的使用方法,包括参数解释和实例演示。put函数用于将指定索引的数组元素替换为给定值,putmask函数则根据布尔数组mask来修改目标数组的值,place函数同样根据条件值更改数组元素,但使用values的前n个元素。最后提到了numpy.copyto函数,用于将一个数组的值复制到另一个数组。" 124038560,12537627,C++入门详解:关键字、命名空间到C++11新特性,"['C++', '编程基础', '函数', '引用', 'C++11']
摘要由CSDN通过智能技术生成

np.put(a, ind, v, mode=‘raise’)

参数解释:
Parameters:
a : ndarray
Target array.

ind : array_like
Target indices, interpreted as integers.

v : array_like
Values to place in a at target indices. If v is shorter than ind it will be repeated as necessary.

mode : {‘raise’, ‘wrap’, ‘clip’}, optional
Specifies how out-of-bounds indices will behave.

‘raise’ – raise an error (default)
‘wrap’ – wrap around
‘clip’ – clip to the range
‘clip’ mode means that all indices that are too large are replaced by the index that addresses the last element along that axis. Note that this disables indexing with negative numbers. In ‘raise’ mode, if an exception occurs the target array may still be modified.(“clip”模式意味着所有太大的索引都将替换为沿该轴寻址最后一个元素的索引。)

表示对数组中指定的索引值指向的元素替换成指定的值。索引在扁平的目标数组上工作
例子:

a = np.array([0,5,6,75,6])
np.put(a, [0,
  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值