| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 31 |
- Presto
- matplotlib
- GIT
- numpy
- math
- hive
- Github
- Google Excel
- PANDAS
- google apps script
- Java
- dataframe
- django
- PostgreSQL
- SQL
- string
- Tkinter
- Apache
- array
- gas
- Python
- 파이썬
- Redshift
- Google Spreadsheet
- c#
- PySpark
- Excel
- Kotlin
- list
- Today
- Total
목록Python/Python numpy (39)
달나라 노트
numpy의 zeros method는 0으로만 채워진 array를 생성합니다. 아래 예시들을 봅시다. import numpy as np arr_test = np.zeros(shape=3) print(arr_test) -- Result [0. 0. 0.] zeros(3)의 의미는 3개의 0을 요소로서 가지는 1차원 array를 생성하라는 의미입니다. 이렇게 zeros는 기본적으로 1차원 array를 생성합니다. import numpy as np arr_test = np.zeros(shape=3, dtype=int) print(arr_test) -- Result [0 0 0] 위 예시처럼 dtype 옵션을 이용해서 data type을 명시해줄 수 있습니다. 위 예시는 0의 data type을 모두 정수(in..
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] ..
