일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- django
- list
- Github
- GIT
- Kotlin
- Excel
- Java
- gas
- Google Spreadsheet
- 파이썬
- Redshift
- Apache
- dataframe
- hive
- string
- c#
- math
- PANDAS
- Tkinter
- PySpark
- SQL
- Python
- google apps script
- array
- numpy
- matplotlib
- Google Excel
- Mac
- PostgreSQL
- Today
- Total
목록Python/Python ETC (57)
달나라 노트
Python으로 데이터를 다루거나 특히 pandas의 to_excel로 엑셀 파일을 생성할 때 illegal character error가 발생할 때가 있습니다. 이는 DataFrame의 어딘가에 illegal character가 포함되어있기 때문이라 이를 제거해주어야 합니다. from openpyxl.cell.cell import ILLEGAL_CHARACTERS_RE...df.loc[:, 'col1'] = df.apply( lambda row: ILLEGAL_CHARACTERS_RE.sub(r'', row['col1']), axis=1) illegal character는 위처럼 openpyxl library의 ILLEGAL_CHARACTERS_RE method를 이용하여 특정 colum..
pynput library로 keyboard를 컨트롤 하는 방법을 알아봅시다.(mac환경에서 진행됩니다.) from pynput.keyboard import Key, Controllerkeyboard = Controller()# press and release spacekeyboard.press(Key.space) # press spacekeyboard.release(Key.space) # release space press, release method를 이용해 keyboard의 key를 눌렀다 뗐다를 할 수 있습니다.press는 어떠한 key를 누르라는 의미이며release는 어떠한 key를 누른 상태에서 떼라는 의미입니다. Key를 for loop를 이용해 출력해보면 어떠한 key들이 Ke..
pynput library로 mouse를 컨트롤 하는 방법을 알아봅시다.(mac환경에서 진행됩니다.) from pynput.mouse import Button, Controllermouse = Controller()print('The current pointer position is {0}'.format(mouse.position)) 위처럼 mouse 객체를 만들면 position attribute는 마우스의 위치를 담고 있습니다. 화면의 왼쪽 가장 위가 (0, 0)이며오른쪽으로 갈수록 x좌표가 양수로 증가하고아래쪽으로 갈수록 y좌표가 양수로 증가합니다. from pynput.mouse import Button, Controllermouse = Controller()# move pointer to ..
Python에서는 PIL module을 이용하여 화면을 캡쳐할 수 있습니다. from PIL import ImageGrab# capture entire screenimg = ImageGrab.grab()img.show() 위처럼 하면 화면 전체를 캡쳐할 수 있습니다. from PIL import ImageGrab# capture top-left rectangle with size 638px wide by 312px tallimg = ImageGrab.grab(bbox=(0, 0, 538, 312))img.show() 위처럼 화면 캡쳐 영역의 크기를 조절할 수도 있습니다. 캡쳐는 직사각형으로 할 수 있으며, bbox에 담겨진 4개의 인자는 각각 직사각형의 꼭지점 좌표를 의미합니다.bbox=(x1, ..