Answers for "np choose explain"

0

np choose explain

>>> 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
Posted by: Guest on January-01-2021

Python Answers by Framework

Browse Popular Code Answers by Language