일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- GIT
- c#
- PySpark
- list
- Github
- numpy
- Tkinter
- Excel
- PANDAS
- django
- google apps script
- Kotlin
- gas
- Mac
- Java
- string
- SQL
- hive
- matplotlib
- Redshift
- 파이썬
- Python
- Google Spreadsheet
- Google Excel
- math
- array
- PostgreSQL
- Apache
- dataframe
- Today
- Total
목록Python/Python numpy (38)
달나라 노트
flatten method는 모든 차원의 array를 1차원으로 바꿔줍니다. 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 ] ) arr_test_flatten = arr_test.flatten() print(arr_test_flatten) print(arr_test_flatten.ndim) print(type(arr_test_flatten)) -- Result [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15] 1 위 예시를 보면 2차원 array가 1차원 array의 형태로 바뀌었음을 알 수 있습니다. 마치 pytho..
numpy에서 T attribute는 numpy array를 transpose해줍니다. 좀 직관적으로 이해하려면 흔히 말하는 행과 열을 바꿔준다는 느낌으로 받아들이면 될 것 같습니다. 아래 예시를 봅시다. import numpy as np arr_test = np.array( [ # 1차 array [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5] # 2차 array ] ) print(arr_test) print(arr_test.shape) arr_test_t = arr_test.T print(arr_test_t) print(arr_test_t.shape) -- Result [[1 2 3 4 5] [1 2 3 4 5] [1 2 3 4 5]] (3, 5) [[1 1 ..
numpy의 ndim attribute는 어떤 array가 몇차원인지를 알려줍니다. 아래는 ndim attribute를 사용한 예시입니다. import numpy as np arr_test = np.array( [1, 2, 3, 4, 5] # 1차 array ) print(arr_test) print(arr_test.ndim) -- Result [1 2 3 4 5] 1 import numpy as np arr_test = np.array( [ # 1차 array [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5] # 2차 array ] ) print(arr_test) print(arr_test.ndim) -- Result [[1 2 3 4 5] [1 2 3 4 5] ..
import numpy as np arr_test = np.array( [ # 1차 array [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5] # 2차 array ] ) print(arr_test) print(arr_test.size) print(arr_test.shape) -- Result [[1 2 3 4 5] [1 2 3 4 5] [1 2 3 4 5]] 15 (3, 5) 위 예시를 봅시다. 2차원 array를 만들고 size와 shape attribute를 적용시켰습니다. size attribute는 array에 존재하는 모든 요소의 개수를 알려줍니다. 위 예시의 array는 5개의 요소를 가진 array가 총 3개 들어있는 2차원 array입니다. 이것을 ..