pandas.Index.argsort#
- Index.argsort(*args, **kwargs)[源代码]#
返回将对索引进行排序的整数索引。
- Parameters:
- *args
传递给 numpy.ndarray.argsort。
- **kwargs
传递给 numpy.ndarray.argsort。
- Returns:
- np.ndarray[np.intp]
如果用作索引器,将用于对索引进行排序的整数索引。
参见
numpy.argsortNumPy 数组的类似方法。
Index.sort_values返回 Index 的已排序副本。
Examples
>>> idx = pd.Index(['b', 'a', 'd', 'c']) >>> idx Index(['b', 'a', 'd', 'c'], dtype='object')
>>> order = idx.argsort() >>> order array([1, 0, 3, 2])
>>> idx[order] Index(['a', 'b', 'c', 'd'], dtype='object')