首页 > 编程知识 正文

python中arr函数,python中clear函数有什么用

时间:2023-05-06 16:34:19 阅读:269694 作者:168

numpy中argsort函数用法,有需要的朋友可以参考下。

在Python中使用help帮助

>>> import numpy

>>> help(numpy.argsort)

Help on function argsort in module numpy.core.fromnumeric:

argsort(a, axis=-1, kind='quicksort', order=None)

Returns the indices that would sort an array.

Perform an indirect sort 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 sorted order.

从中可以看出argsort函数返回的是数组值从小到大的索引值

Examples

--------

One dimensional array:一维数组

>>> x = np.array([3, 1, 2])

>>> np.argsort(x)

array([1, 2, 0])

Two-dimensional array:二维数组

>>> x = np.array([[0, 3], [2, 2]])

>>> x

array([[0, 3],

[2, 2]])

>>> np.argsort(x, axis=0) #按列排序

array([[0, 1],

[1, 0]])

>>> np.argsort(x, axis=1) #按行排序

array([[0, 1],

[0, 1]])

W WW.002pc .COM从python 多个条件判断numpy中argsort函数用法分析来看,对python 多个条件判断numpy中argsort函数用法的结果。#######################################

例1:

>>> x = np.array([3, 1, 2])

>>> np.argsort(x) #按升序排列

array([1, 2, 0])

>>> np.argsort(-x) #按降序排列

array([0, 2, 1])

>>> x[np.argsort(x)] #通过索引值排序后的数组

array([1, 2, 3])

>>> x[np.argsort(-x)]

array([3, 2, 1])

另一种方式实现按降序排序:

>>> a = x[np.argsort(x)]

>>> a

array([1, 2, 3])

>>> a[::-1]

array([3, 2, 1])

另外说到排序,还有两个常用的函数sort和sorted,详细内容请看:http://怕孤单的冬日.blog.163.com/blog/static/171557351201424105925681/?newFollowBlog

更多:python 多个条件判断numpy中argsort函数用法

https://www.002pc.comhttps://www.002pc.com/python/1297.html

你可能感兴趣的numpy,argsort,用法,函数

cxml phpPHP构造函数与析构函数用法示例

本文实例讲述了PHP构造函数与析构函数用法。分享给大家供大家参考,具体如下:

在实例化一个新对象时,构造方法和析构方法都会被自动调用,若有继承则会使用父类的对应方法。

析构

html的phpPHP中ini_set和ini_get函数的用法小结

电脑技术网从html的phpPHP中ini_set和ini_get函数的用法小结分析来看,对html的phpPHP中ini_set和ini_get函数的用法小结的结果。

php适合小程序的后台php的dl函数用法实例

本文实例讲述了php的dl函数用法。分享给大家供大家参考。

php编辑器noThinkphp getLastSql函数用法

如何判断一个更新操作是否成功:电脑技术002pc网对《php编辑器noThinkphp getLastSql函数用法》总结来说,为我们php开源很实用。

php如何访问apiphp中mkdir函数用法实例分析

本文实例分析了php中mkdir函数用法。分享给大家供大家参考。

mac 默认配置php-fpm嘛php中mt_rand()随机数函数用法

本文实例讲述了php中mt_rand()随机数函数用法。分享给大家供大家参考。具体分析如下:

mt_rand() 使用 mersenne twister 算法返回随机整数.

win7旗舰版本地测aspASP中Split分割字符串函数的实例用法

ASP中Split函数的用法 分割截取字符串看几个例子就能理解了

复制代码 代码如下:mystr="1,2,3,4,5" mystr=split(mystr,",&quot

0踩

0 赞

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。