Numpy 求最小值矩阵的某一行并返回其索引

Examples
    --------
    >>> a = np.arange(6).reshape(2,3) + 10
    >>> a
    array([[10, 11, 12],
           [13, 14, 15]])
    >>> np.argmin(a)
    0
    >>> np.argmin(a, axis=0)  # This is for the matrix, and the 
    array([0, 0, 0])
    >>> np.argmin(a, axis=1) #  For the row.
    array([0, 0])  

 >>> b = np.arange(6) + 10
    >>> b[4] = 10
    >>> b
    array([10, 11, 12, 13, 10, 15])
    >>> np.argmin(b)  # Only the first occurrence is returned,the method is used frequently.
    0

你可能感兴趣的:(Python-daily,Numpy)