일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- PostgreSQL
- math
- SQL
- PANDAS
- list
- GIT
- Python
- array
- hive
- Mac
- Github
- django
- PySpark
- string
- dataframe
- Redshift
- Google Excel
- Tkinter
- Google Spreadsheet
- google apps script
- numpy
- Java
- c#
- gas
- Excel
- Kotlin
- 파이썬
- Apache
- matplotlib
- Today
- Total
목록2024/03 (20)
달나라 노트
Python의 내장함수 oct()는 10진수를 8진수로 변환해줍니다. print(oct(12)) -- Result 0o14 12를 8진수로 바꿔보았습니다. 결과에 있는 0o를 지우면 14가 되는데, 바로 이 부분이 8진수를 의미합니다. (0o에서 o는 oct를 의미하며 8진수를 뜻합니다.) 14를 10진수로 변환해보면 실제로 5가 나옵니다.
Python의 내장함수 bin()은 10진수를 2진수로 변환해줍니다. print(bin(5)) -- Result 0b101 5를 2진수로 바꿔보았습니다. 결과에 있는 0b를 지우면 101이 되는데, 바로 이 부분이 2진수를 의미합니다. 101 을 10진수로 변환해보면 실제로 5가 나옵니다.
opencv는 이미지 처리 기능, 머신러닝 등의 기능을 제공하는 툴 입니다. opencv를 이용해 간단하게 원하는 크기의 원하는 색상의 이미지를 만들어봅시다. 이를 위해선 numpy array가 필요합니다. import numpy as npimport cv2arr_for_img = np.zeros(shape=(800, 500), dtype=float) # 행 개수 800개, 열 개수 500개의 0으로 채워진 2차원 array 생성print(arr_for_img)cv2.imwrite('img_black.png', arr_for_img) # array를 이용하여 png image 생성-- Result[[0. 0. 0. ... 0. 0. 0.] [0. 0. 0. ... 0. 0. 0.] [0. 0. ..
numpy의 ones() method는 1로만 채워진 array를 생성합니다. 아래 예시들을 봅시다. import numpy as np arr_ones = np.ones(shape=3) print(arr_ones) -- Result [1. 1. 1.] ones(3)의 의미는 3개의 1을 요소로서 가지는 1차원 array를 생성하라는 의미입니다. 이렇게 ones() method는 기본적으로 1차원 array를 생성합니다. import numpy as np arr_ones = np.ones(shape=3, dtype=int) print(arr_ones) -- Result [1 1 1] 위 예시처럼 dtype 옵션을 이용해서 data type을 명시해줄 수 있습니다. 위 예시는 1의 data type을 모두 ..