Skip to content Skip to sidebar Skip to footer

Multiple Ranges Of Numpy Array Returned

Suppose there is an array like the below: a = np.array([[1,2], [2,3], [2,3], [2,3], [4,5], [3,4],

Solution 1:

This works:

>>> a[np.r_[:2, 5:6], :]
array([[1, 2],
       [2, 3],
       [3, 4]])

The np.r_:

Translates slice objects to concatenation along the first axis.

Post a Comment for "Multiple Ranges Of Numpy Array Returned"