📜  np 选择解释 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:48.006000             🧑  作者: Mango

代码示例1
>>> a = np.array([[1, 2, 3, 4], 
                  [5, 6, 7, 8], 
                  [9, 10, 11, 12], 
                  [13, 14, 15, 16]])
>>> np.choose([0, 2, 1, 3], a)
array([ 1, 10,  7, 16]) # one from each row
>>> np.take(a, [0, 2, 1, 3])
array([1, 3, 2, 4]) # all from same row