MCPcopy
hub / github.com/pandas-dev/pandas / argsort

Method argsort

pandas/core/indexes/base.py:6051–6088  ·  view source on GitHub ↗

Return the integer indices that would sort the index. Parameters ---------- *args Passed to `numpy.ndarray.argsort`. **kwargs Passed to `numpy.ndarray.argsort`. Returns ------- np.ndarray[np.intp]

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

6049 )
6050
6051 def argsort(self, *args, **kwargs) -> npt.NDArray[np.intp]:
6052 """
6053 Return the integer indices that would sort the index.
6054
6055 Parameters
6056 ----------
6057 *args
6058 Passed to `numpy.ndarray.argsort`.
6059 **kwargs
6060 Passed to `numpy.ndarray.argsort`.
6061
6062 Returns
6063 -------
6064 np.ndarray[np.intp]
6065 Integer indices that would sort the index if used as
6066 an indexer.
6067
6068 See Also
6069 --------
6070 numpy.argsort : Similar method for NumPy arrays.
6071 Index.sort_values : Return sorted copy of Index.
6072
6073 Examples
6074 --------
6075 >>> idx = pd.Index(["b", "a", "d", "c"])
6076 >>> idx
6077 Index(['b', 'a', 'd', 'c'], dtype='str')
6078
6079 >>> order = idx.argsort()
6080 >>> order
6081 array([1, 0, 3, 2])
6082
6083 >>> idx[order]
6084 Index(['a', 'b', 'c', 'd'], dtype='str')
6085 """
6086 # This works for either ndarray or EA, is overridden
6087 # by RangeIndex, MultIIndex
6088 return self._data.argsort(*args, **kwargs)
6089
6090 def _check_indexing_error(self, key) -> None:
6091 if not is_scalar(key):

Callers 10

_join_emptyMethod · 0.95
_merge_blocksFunction · 0.45
stack_v3Function · 0.45
sort_valuesMethod · 0.45
computeMethod · 0.45
result_index_and_idsMethod · 0.45
_ob_index_and_idsMethod · 0.45
_set_grouperMethod · 0.45
_transform_with_numbaMethod · 0.45

Calls

no outgoing calls

Tested by 1