当前位置:   article > 正文

Numpy的argsort()方法_argsort() received an invalid combination of argum

argsort() received an invalid combination of arguments - got (axis=int, kind

numpy.argsort(a, axis=-1, kind=None, 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.


    使用kind关键字指定的算法沿给定轴执行间接排序。它返回一个数组的索引相同的形状作为一个索引数据沿给定的轴排序。

—————————————————————————————————————————————

  • Parameters 参数:
    a: array_like
    Array to sort.

  • axis: int or None, optional
    Axis along which to sort. The default is -1 (the last axis). If None, the flattened array is used.

  • kind: {‘quicksort’, ‘mergesort’, ‘heapsort’, ‘stable’}, optional
    Sorting algorithm. The default is ‘quicksort’. Note that both ‘stable’ and ‘mergesort’ use timsort under the covers and, in general, the actual implementation will vary with data type. The ‘mergesort’ option is retained for backwards compatibility.


    默认是快速排序。注意,稳定和归并排序都在幕后使用timsort,通常,实际实现会随着数据类型的不同而有所不同。保留归并排序选项是为了向后兼容

    注:Changed in version 1.15.0.: The ‘stable’ option was added.

  • order: str or list of str, optional
    When a is an array with fields defined, this argument specifies which fields to compare first, second, etc. A single field can be specified as a string, and not all fields need be specified, but unspecified fields will still be used, in the order in which they come up in the dtype, to break ties.


    当a是一个定义了字段的数组时,这个参数指定首先比较哪个字段,然后比较哪个字段,等等。可以将单个字段指定为字符串,并且不需要指定所有字段,但仍将使用未指定的字段(按它们在dtype中出现的顺序)来断开连接

—————————————————————————————————————————————

  • Returns 返回类型:

  • index_array: ndarray, int
    Array of indices that sort a along the specified axis. If a is one-dimensional, a[index_array] yields a sorted a. More generally, np.take_along_axis(a, index_array, axis=axis) always yields the sorted a, irrespective of dimensionality.


    将a沿指定轴排序的索引数组。如果a是一维的,则[index_array]产生一个排序后的a。take_along_axis(a, index_array, axis=axis)总是生成排序后的a,而不考虑维数。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/648860
推荐阅读
相关标签
  

闽ICP备14008679号