반응형
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 |
Tags
- 파이썬
- Kotlin
- Excel
- list
- hive
- Google Spreadsheet
- array
- Tkinter
- PANDAS
- google apps script
- Google Excel
- gas
- matplotlib
- Java
- string
- Mac
- PostgreSQL
- c#
- Apache
- GIT
- Github
- django
- Python
- numpy
- PySpark
- SQL
- Redshift
- dataframe
- math
Archives
- Today
- Total
달나라 노트
Python numpy : min, max (np.min, np.max, 최소값, 최대값) 본문
Python/Python numpy
Python numpy : min, max (np.min, np.max, 최소값, 최대값)
CosmosProject 2021. 12. 29. 01:06728x90
반응형
numpy의 min, max method는 각각 주어진 값들 중 최소값, 최대값을 return합니다.
import numpy as np
arr_test = np.array([1, 2, 3, 4, 5])
print(arr_test)
print(np.min(arr_test))
print(np.max(arr_test))
-- Result
[1 2 3 4 5]
1
5
arr_test에서 각각 최소값, 최대값이 return됩니다.
import numpy as np
arr_test = np.array(
[ # 1차 array
[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] # 2차 array
]
)
print(arr_test)
print(np.min(arr_test))
print(np.max(arr_test))
-- Result
[[ 1 2 3 4 5]
[ 6 7 8 9 10]
[11 12 13 14 15]]
1
15
다차원 array여도 모든 최소단위의 요소 중 최소값, 최대값을 return합니다.
import numpy as np
list_test = [1, 2, 3, 4, 5]
print(list_test)
print(np.min(list_test))
print(np.max(list_test))
-- Result
[1, 2, 3, 4, 5]
1
5
numpy의 min, max는 array에만 적용한 것이 아니라 list에도 적용 가능합니다. (다양하게 사용할 수 있습니다.)
import numpy as np
list_test = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]
print(list_test)
print(np.min(list_test))
print(np.max(list_test))
-- Result
[[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]
1
15
728x90
반응형
'Python > Python numpy' 카테고리의 다른 글
Comments