| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- Google Excel
- gas
- numpy
- hive
- Excel
- SQL
- 파이썬
- c#
- list
- Tkinter
- GIT
- math
- Presto
- Python
- matplotlib
- django
- array
- google apps script
- Kotlin
- Google Spreadsheet
- Apache
- PANDAS
- Github
- Java
- dataframe
- PostgreSQL
- string
- PySpark
- Redshift
- Today
- Total
목록Python/Python numpy (39)
달나라 노트
Python numpy library에는 난수(랜덤한 숫자)를 생성하는 method들이 있는데 어떤 것들이 있고 어떻게 사용할 수 있는지 알아봅시다. - numpy.random.rand() rand method는 0 이상 1 미만의 랜덤한 실수를 생성합니다. import numpy as np test_value = np.random.rand() print(test_value) -- Result 0.11999006968888681 import numpy as np test_value = np.random.rand(3) print(test_value) -- Result [0.56929945 0.43654139 0.87778867] 위 예시처럼 rand method에 숫자를 넣어주면 넣은 숫자의 길이만큼 랜덤..
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_tes..
numpy의 tolist method는 array를 python의 list로 바꿔줍니다. 변경할 때 array의 차원을 그대로 유지합니다. 2차원 array에 tolist를 적용시키면 list속에 다른 list가 있는 2차원 list의 형태로 반환해준다는 의미이죠. 아래 예시들을 봅시다. import numpy as np arr_test = np.array( [1, 2, 3, 4, 5] # 1차 array ) list_test = arr_test.tolist() print(arr_test) print(list_test) -- 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, ..
import numpy as np arr_test = np.array([1, 2, 3, 4, 5]) arr_test_2 = arr_test arr_test_2[1] = 10 print(arr_test) print(arr_test_2) 위 예시를 봅시다. arr_test에 [1, 2, 3, 4, 5]를 array로 만들어서 할당했습니다. 그리고 arr_test_2 변수에 arr_test를 그대로 할당하교있죠. 이 시점에서 arr_test == arr_test_2일 것입니다. arr_test_2[1] = 10 그리고 arr_test_2의 index = 1 값을 10으로 바꿨죠. 그러면 당연히 arr_test_2는 아래와 같이 바뀔겁니다. [ 1 10 3 4 5] 그러면 이때 arr_test는 [1 2 3 4..
