일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- google apps script
- PANDAS
- gas
- Tkinter
- math
- SQL
- Kotlin
- array
- Google Spreadsheet
- Google Excel
- Python
- hive
- PostgreSQL
- list
- GIT
- Excel
- string
- Github
- c#
- Apache
- Mac
- PySpark
- numpy
- Redshift
- 파이썬
- django
- matplotlib
- Java
- dataframe
- Today
- Total
목록NP (4)
달나라 노트
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차 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입니다. 이것을 ..