1.tile函数:

tile函数是模板numpy.lib.shape_base中的函数。函数的形式是tile(A,reps),A的类型几乎所有类型都可以:array, list, tuple, dict, matrix以及基本数据类型int, string, float以及bool类型。reps的类型也很多,可以是tuple,list, dict, array, int,bool.但不可以是float, string, matrix类型。

>>> from numpy import *
>>> tile(2,3)
array([2, 2, 2])
>>> tile((2,3),2)
array([2, 3, 2, 3])
>>> a=[[1,3],[2,4]]
>>> tile(a,3)
array([[1, 3, 1, 3, 1, 3],[2, 4, 2, 4, 2, 4]])
>>> tile(a,[2,2])
array([[1, 3, 1, 3],[2, 4, 2, 4],[1, 3, 1, 3],[2, 4, 2, 4]])
>>> tile(a,[1,3])
array([[1, 3, 1, 3, 1, 3],[2, 4, 2, 4, 2, 4]])
>>> a
[[1, 3], [2, 4]]

2.shape函数
shape函数是numpy.core.fromnumeric中的函数,它的功能是读取矩阵的长度,比如shape[0]就是读取矩阵第一维度的长度。它的输入参数可以使一个整数表示维度,也可以是一个矩阵。

>>> b=eye(2)
>>> b
array([[ 1.,  0.],[ 0.,  1.]])
>>> b.shape
(2, 2)

3.argsort函数

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 specifiedby 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.Parameters----------a : array_likeArray to sort.axis : int or None, optionalAxis along which to sort.  The default is -1 (the last axis). If None,the flattened array is used.kind : {'quicksort', 'mergesort', 'heapsort'}, optionalSorting algorithm.order : list, optionalWhen `a` is an array with fields defined, this argument specifieswhich fields to compare first, second, etc.  Not all fields need bespecified.Returns-------index_array : ndarray, intArray of indices that sort `a` along the specified axis.In other words, ``a[index_array]`` yields a sorted `a`.See Also--------sort : Describes sorting algorithms used.lexsort : Indirect stable sort with multiple keys.ndarray.sort : Inplace sort.Notes-----See `sort` for notes on the different sorting algorithms.As of NumPy 1.4.0 `argsort` works with real/complex arrays containingnan values. The enhanced sort order is documented in `sort`.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]])>>> xarray([[0, 3],[2, 2]])>>> np.argsort(x, axis=0)array([[0, 1],[1, 0]])>>> np.argsort(x, axis=1)array([[0, 1],[0, 1]])Sorting with keys:>>> x = np.array([(1, 0), (0, 1)], dtype=[('x', '<i4'), ('y', '<i4')])>>> xarray([(1, 0), (0, 1)],dtype=[('x', '<i4'), ('y', '<i4')])>>> np.argsort(x, order=('x','y'))array([1, 0])>>> np.argsort(x, order=('y','x'))array([0, 1])

参考:

http://www.ithao123.cn/content-770921.html

http://blog.csdn.net/maoersong/article/details/21875705

python之tile函数,shape函数,argsort函数介绍相关推荐

  1. python argsort函数_Python numpy.argsort函数方法的使用

    numpy.argsort numpy.argsort(a, axis=-1, kind=None, order=None)      [source] 返回将对数组进行排序的索引. 使用kind关键 ...

  2. python的argsort函数_python——argsort函数

    numpy中argsort函数用法,有需要的朋友可以参考下. 在Python中使用help帮助 >>> import numpy >>> help(numpy.ar ...

  3. python中argsort_(学习笔记)numpy中argsort函数用法

    在Python中使用help帮助 >>> import numpy >>> help(numpy.argsort) Help on function argsort ...

  4. python中argsort_浅述python中argsort()函数的实例用法

    由于想使用python用训练好的caffemodel来对很多图片进行批处理分类,学习过程中,碰到了argsort函数,因此去查了相关文献,也自己在python环境下进行了测试,大概了解了其相关的用处, ...

  5. python:shape和reshape()函数

    在numpy中,shape和reshape()函数很常用.二者的功能都是对于数组的形状进行操作. shape函数可以了解数组的结构: reshape()函数可以对数组的结构进行改变. shape im ...

  6. python中argsort()函数的用法

    由于想使用python用训练好的caffemodel来对很多图片进行批处理分类,学习过程中,碰到了argsort函数,因此去查了相关文献,也自己在python环境下进行了测试,大概了解了其相关的用处, ...

  7. 浅述python中argsort()函数的用法

    由于想使用python用训练好的caffemodel来对很多图片进行批处理分类,学习过程中,碰到了argsort函数,因此去查了相关文献,也自己在python环境下进行了测试,大概了解了其相关的用处, ...

  8. python argsort(0)_【Python】numpy中argsort函数的使用

    1.概述 argsort()函数在模块numpy.core.fromnumeric中. 函数形式是: help (numpy.argsort) Help on function argsort in ...

  9. python sort函数排序_Python中排序常用到的sort 、sorted和argsort函数

    argsort函数返回的是数组值从小到大的索引值 Examples -------- One dimensional array:一维数组 >>> x = np.array([3, ...

  10. python中argsort()函数

    argsort()函数是对数组中的元素进行从小到大排序,并返回相应序列元素的数组下标. 1. 直接调用argsort()函数 由上图可知,输出的结果是x数组中的元素从小到大排序后的索引数组值,如x数组 ...

最新文章

  1. 程序员面试题精选100题(05)-查找最小的k个元素[算法]
  2. HDU 2066 一个人的旅行
  3. 中国大学MOOC 计算机组成原理第1章测试
  4. ES5-19 变量声命周期、垃圾回收原理、arguments
  5. 现代软件工程 第四章 【结对编程】练习与讨论
  6. JSONObject转换JSON--将Date转换为指定格式
  7. 小练习-----银行提款机系统
  8. Scala For Java的一些参考
  9. Oracle学习笔记(1)----忘记用户名的密码该如何找回
  10. python计算三角函数的计算器_一个工具箱 之 三角函数计算器
  11. win10系统dnf安装不上服务器失败,win10系统玩dnf图表系统组建失败怎么修复
  12. PHP连接mysql原生代码
  13. 为何觉得静态ip比动态ip的网速更快
  14. 【python逻辑算法题】一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法
  15. Depmap分析、可视化CCLE数据
  16. 麻雀要革命 第三章 宣战!麻雀联盟的华丽出击 第二节
  17. 程序员做外包,真的没地位没出路吗
  18. 腾讯服务器状态异常是怎么回事啊,腾讯云服务器网络异常怎么办
  19. OpenHarmony鸿蒙相关资料
  20. 高中信息技术html语言,高中信息技术《Python语言》模块试卷

热门文章

  1. [20个项目学会BBC micro:bit编程] 12-蜂鸣器控制
  2. IBM服务器诊断面板
  3. 【matlab】在图中插入矩形(框or阴影)
  4. 课程设计之第二次冲刺----第一天
  5. 关于web开发的一点理解
  6. BCD码干什么用的?
  7. 从TIN获取任意坐标点高程(原创)
  8. MySQL Merge存储引擎
  9. mysql版本问题,最近多次遇到的坑
  10. 内存泄漏分析工具tMemoryMonitor(转载)