numpy argsort
2023-09-14 09:11:20 时间
转自:https://blog.csdn.net/u011475210/article/details/77770751
1.例子
import numpy as np x = np.array([3, 1, 2]) y=np.argsort(x) z=x[y] >>> y array([1, 2, 0], dtype=int64) >>> z array([1, 2, 3])
argsort过程,第一步先sort得到由小到大的数组(一维不指定轴,高维需要指定轴),排序后的数组中的值在原数组中对应的索引就是此函数的返回值。
相关文章
- NumPy学习(索引和切片,合并,分割,copy与deep copy)
- NumPy事例练习
- 基于Python中numpy数组的合并实例讲解
- [Python] Indexing An Array With Another Array with numpy
- 成功解决numpy.ndarray格式类型转数据为list格式数据带有中括号(一行代码搞定!)
- 成功解决numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares
- 成功解决ImportError: Something is wrong with the numpy installation. While importing we detected an olde
- Numpy常用操作方法
- Lesson8——NumPy 高级索引
- 数据分析----numpy数组的索引和切片操作