본문 바로가기
python

넘파이 최대값 최소값, 넘파이 행별 최대값

by 타닥타닥 토다토닥 부부 2023. 6. 22.
반응형

넘파이 최대값 최소값, 넘파이 행별 최대값

최대값 np.max

import numpy as np
arr = np.array(
    [[5,8,5,3,3], 
     [2,1,3,0,0]]
)

np.max(arr)

# out: 8

 

최소값 np.min

import numpy as np
arr = np.array(
    [[5,8,5,3,3], 
     [2,1,3,0,0]]
)

np.min(arr)

# out : 0

 

행별 최대값 np.max axis=1

import numpy as np
arr = np.array(
    [[5,8,5,3,3], 
     [2,1,3,0,0]]
)

np.max(arr, axis=1)

# out : array([8, 3])

 

 

열별 최대값 np.max axis=1

import numpy as np
arr = np.array(
    [[5,8,5,3,3], 
     [2,1,3,0,0]]
)

np.max(arr, axis=0)

# out : array([5, 8, 5, 3, 3])

 

 

반응형

댓글