numpy求数组某行某列的最大值


Examples

a = np.arange(4).reshape((2,2))
a
array([[0, 1],
       [2, 3]])
np.amax(a)           # Maximum of the flattened array
3
np.amax(a, axis=0)   # Maxima along the first axis
array([2, 3])
np.amax(a, axis=1)   # Maxima along the second axis
array([1, 3])
np.amax(a, where=[False, True], initial=-1, axis=0)
array([-1,  3])
b = np.arange(5, dtype=float)
b[2] = np.NaN
np.amax(b)
nan
np.amax(b, where=~np.isnan(b), initial=-1)
4.0
np.nanmax(b)
4.0

你可能感兴趣的:(链表,数据结构,list)