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

image를 ASCII character를 이용한 그림으로 변환할 수 있습니다. 변환할 image인 apple.png는 다음과 같습니다. apple 로고를 변환해볼게요. import PIL.Image # list of ascii characters used when convert image to ascii text list_ascii_chars = ['@', '#', 'S', '%', '?', '*', '+', ';', ':', ',', '.'] # resize image according to a new width def resize_image(pil_obj_image, new_width): width, height = pil_obj_image.size # obj_image = image object ..
notes = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'] print(notes.index('A')) print(notes.index('C')) -- Result 9 0 list에 index(value)를 적용하면 value를 list내에서 찾아 그 value의 index를 반환해줍니다.
3의 5승(3 ^ 5)을 영어로 표현하면 3 to the power of 5 입니다. 이렇게 거듭제곱을 표현하는 단어는 영어에서 power라는 단어인데 이 단어의 앞글자를 딴 method가 Python에 존재합니다. pow(n, m) .위처럼 사용할 수 있으며 n의 m승(n ^ m)을 의미합니다. print(pow(2, 3)) print(pow(3, 2)) print(pow(8, 2)) -- Result 8 9 64
numpy의 concatenate는 list나 array등을 하나의 list또는 array로 합쳐줍니다. import numpy as np x = [1, 2, 3, 4, 5] y = [1, 2, 3, 4, 5] print(np.concatenate([x, y])) -- Result [1 2 3 4 5 1 2 3 4 5] 위 예시는 2개의 list를 합친 것입니다. import numpy as np x = np.array([ [1, 2], [3, 4] ]) y = np.array([ [5, 6], [7, 8], [9, 10] ]) print(np.concatenate([x, y])) -- Result [[ 1 2] [ 3 4] [ 5 6] [ 7 8] [ 9 10]] 위 예시는 2개의 array를 하나로 ..