Python
[파이썬] Array(ex. 2차원 배열)에서 max값만 추출하는 방법
koos808
2020. 11. 1. 16:57
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))
[1, 2, 2, 3, 4]
>>> max(map(max, numbers))
4
>>> import numpy as np
>>> np.max(numbers)
4
728x90
반응형