理解numpy.where

  • numpy.where(condition[, x, y])

    Return elements chosen from x or y depending on condition.

    >>> a = np.arange(10)
    >>> np.where(a<5, a, 10*a)
    array([0,1,2,3,4,50,60,70,80,90])
    

你可能感兴趣的:(#,小白学Python,numpy.where)