Perform an indirect partition along the given axis using the algorithm specified by the kind keyword. It returns an array of indices of the same shape as a that index data along the given axis in partitioned order.
New in version 1.8.0.
Parameters: | a : array_like
kth : int or sequence of ints
axis : int or None, optional
kind : {‘introselect’}, optional
order : list, optional
|
---|---|
Returns: | index_array : ndarray, int
|
See also
Notes
See partition for notes on the different selection algorithms.
Examples
One dimensional array:
>>> x = np.array([3, 4, 2, 1])
>>> x[np.argpartition(x, 3)]
array([2, 1, 3, 4])
>>> x[np.argpartition(x, (1, 3))]
array([1, 2, 3, 4])