【发布时间】:2019-07-28 18:09:34
【问题描述】:
我有一个二维数组:
a = np.random.randint(100, size=(6, 4))
[[72 76 40 11]
[48 82 6 87]
[53 24 25 99]
[ 7 94 82 90]
[28 81 10 9]
[94 99 67 58]]
还有一个一维数组:
idx = np.random.randint(4, size=6)
[0, 3, 2, 1, 0, 2]
是否可以对二维数组进行索引,使得结果为:
a[idx]
[72, 87, 25, 94, 28, 67]
【问题讨论】:
标签: python arrays numpy indexing