Return an ndarray of indices that sort the array along the specified axis. Masked values are filled beforehand to `fill_value`. Parameters ---------- axis : int, optional Axis along which to sort. If None, the default, the flattened arra
(self, axis=np._NoValue, kind=None, order=None, endwith=True,
fill_value=None, *, stable=False, descending=False)
| 5605 | return out |
| 5606 | |
| 5607 | def argsort(self, axis=np._NoValue, kind=None, order=None, endwith=True, |
| 5608 | fill_value=None, *, stable=False, descending=False): |
| 5609 | """ |
| 5610 | Return an ndarray of indices that sort the array along the |
| 5611 | specified axis. Masked values are filled beforehand to |
| 5612 | `fill_value`. |
| 5613 | |
| 5614 | Parameters |
| 5615 | ---------- |
| 5616 | axis : int, optional |
| 5617 | Axis along which to sort. If None, the default, the flattened array |
| 5618 | is used. |
| 5619 | kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional |
| 5620 | The sorting algorithm used. |
| 5621 | order : str or list of str, optional |
| 5622 | When `a` is an array with fields defined, this argument specifies |
| 5623 | which fields to compare first, second, etc. Not all fields need be |
| 5624 | specified. |
| 5625 | endwith : {True, False}, optional |
| 5626 | Whether missing values (if any) should be treated as the largest values |
| 5627 | (True) or the smallest values (False) |
| 5628 | When the array contains unmasked values at the same extremes of the |
| 5629 | datatype, the ordering of these values and the masked values is |
| 5630 | undefined. |
| 5631 | fill_value : scalar or None, optional |
| 5632 | Value used internally for the masked values. |
| 5633 | If ``fill_value`` is not None, it supersedes ``endwith``. |
| 5634 | stable : bool, optional |
| 5635 | Only for compatibility with ``np.argsort``. Ignored. |
| 5636 | descending : bool, optional |
| 5637 | Only for compatibility with ``np.sort``. Ignored. |
| 5638 | |
| 5639 | Returns |
| 5640 | ------- |
| 5641 | index_array : ndarray, int |
| 5642 | Array of indices that sort `a` along the specified axis. |
| 5643 | In other words, ``a[index_array]`` yields a sorted `a`. |
| 5644 | |
| 5645 | See Also |
| 5646 | -------- |
| 5647 | ma.MaskedArray.sort : Describes sorting algorithms used. |
| 5648 | lexsort : Indirect stable sort with multiple keys. |
| 5649 | numpy.ndarray.sort : Inplace sort. |
| 5650 | |
| 5651 | Notes |
| 5652 | ----- |
| 5653 | See `sort` for notes on the different sorting algorithms. |
| 5654 | |
| 5655 | Examples |
| 5656 | -------- |
| 5657 | >>> import numpy as np |
| 5658 | >>> a = np.ma.array([3,2,1], mask=[False, False, True]) |
| 5659 | >>> a |
| 5660 | masked_array(data=[3, 2, --], |
| 5661 | mask=[False, False, True], |
| 5662 | fill_value=999999) |
| 5663 | >>> a.argsort() |
| 5664 | array([1, 0, 2]) |