koos808

[파이썬] 각 array에서 max값만 추출하는 방법 본문

Python

[파이썬] 각 array에서 max값만 추출하는 방법

koos808 2020. 10. 30. 22:48
728x90
반응형

# 각 array(ex.2차원 배열)에서 max값만 추출하는 파이썬 코드

numbers = [0, 0, 1, 0, 0, 1], [0, 1, 0, 2, 0, 0], [0, 0, 2, 0, 0, 1], [0, 1, 0, 3, 0, 0], [0, 0, 0, 0, 4, 0]

>>> map(max, numbers)
<map object at 0x0000018E8FA237F0>

>>> list(map(max, numbers))  # max numbers from each sublist
[1, 2, 2, 3, 4]

>>> max(map(max, numbers))  # max of those max-numbers
4  

728x90
반응형
Comments