![](/img/trans.png)
[英]Pythonic way to replace specific values with other values of numpy array within particular indices
[英]How replace values from one numpy array by other array with indices
我有两个 arrays 和一个带索引的列表
阵列源(阵列01):
x = np.array([[1,2,3], [4,5,6], [7,8,9]])
array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
具有新值的数组(数组 02):
y = np.array([11, 22, 33])
array([11, 22, 33])
和一个索引列表
a = [1,2,1]
[1, 2, 1]
我需要根据索引替换数组 01 中数组 02 的值
预期回报:
array([[1, 11, 3],
[4, 5, 22],
[7, 33, 9]])
如何在没有循环的情况下做到这一点?
提前致谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.