[英]Fancy Indexing in NumPy
What is happening here??这里发生了什么? I'm not able to get it.
我无法得到它。
a = np.arange(12).reshape(3,4)
i = np.array( [ [0,1],[1,2] ] )
j = np.array( [ [2,1],[3,3] ] )
print(a[i,j])
Output looks like this输出看起来像这样
[[ 2, 5],
[ 7, 11]]
Maybe this rearrangement of the indices will help也许这种索引的重新排列会有所帮助
[0,1], [2,1]
[1,2], [3,3]
or或者
(0,2) (1,1)
(1,3) (2,3)
It's picking 4 values, using the 4 indices from each of the 2 arrays.它使用来自 2 个数组中的每一个的 4 个索引来选择 4 个值。
a[0,2], a[1,1] etc a[0,2], a[1,1] 等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.