Python
-
새로운 데이터 타입으로 변환Python/Pandas 2023. 1. 18. 07:23
df.convert_dtypes() https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.convert_dtypes.html 1.0 버전에 추가됨. 공식 문서의 예를 살펴보자. >>> df = pd.DataFrame( ... { ... "a": pd.Series([1, 2, 3], dtype=np.dtype("int32")), ... "b": pd.Series(["x", "y", "z"], dtype=np.dtype("O")), ... "c": pd.Series([True, False, np.nan], dtype=np.dtype("O")), ... "d": pd.Series(["h", "i", np.nan], dtype=np.dtype("O")),..
-
파이썬 정렬Python/이것저것 파이썬 2022. 12. 31. 20:56
기본 print(sorted([5, 2, 3, 1, 4])) # [1, 2, 3, 4, 5] print(sorted([5, 2, 3, 1, 4], reverse=True)) # [5, 4, 3, 2, 1] a = [5, 2, 3, 1, 4] a.sort() print(a) # [1, 2, 3, 4, 5] print(sorted({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'})) # [1, 2, 3, 4, 5] 키 student_tuples = [ ('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10), ] print(sorted(student_tuples, key=lambda student: student[2])) # sort by a..
-
사다리 게임Python/이것저것 파이썬 2022. 12. 28. 22:32
from random import randint, shuffle def main(member_num, line_num): members = list(range(1, 1 + member_num)) # 1번부터 targets = list(chr(each + ord('A')) for each in range(member_num)) # A 부터 ladder = [[False for _ in range(member_num - 1)] for _ in range(line_num)] # 가로선 선택 full_col = set(range(line_num)) prev_col = set() for i in range(member_num - 1): # 좌에서 우로, 마지막 열은 가로선 없음. temp = list(full_c..
-
pyttsx3Python/이것저것 파이썬 2022. 12. 23. 15:39
pip install pyttsx3 import pyttsx3 engine = pyttsx3.init() engine.setProperty('rate', 120) engine.say('안녕하세요?') engine.runAndWait() https://github.com/nateshmbhat/pyttsx3 GitHub - nateshmbhat/pyttsx3: Offline Text To Speech synthesis for python Offline Text To Speech synthesis for python. Contribute to nateshmbhat/pyttsx3 development by creating an account on GitHub. github.com https://pyttsx3.r..
-
파이참, 깃헙 데스크탑 초기 설정Python/이것저것 파이썬 2022. 12. 23. 10:37
파이참 공식 기능을 쓰십시오. 파이참도 공식적으로 깃헙을 지원하기 때문에 파이참에서 제공되는 기능을 쓰면 됩니다. 저는 깃헙 데스크탑만 쓰는 게 편해서 저는 깃헙을 GUI로 시작했고.... 이런 저런 개발환경을 두루 두루 사용해 오다 보니, 파이참의 깃헙 지원보다는 깃헙 데스크탑이 편해서... 이런 방법으로 레포지토리를 생성합니다. 깃헙 데스크탑만으로 기존 폴더를 레포지토리로 설정하는 법 이 글은 깃헙 데스크탑 만으로 기존 폴더를 레포지토리로 설정하는 법에 대한 글입니다. 저는 로컬에서 어느 정도 작업이 이루어진 뒤에, 깃헙에 올리는 경우가 많습니다. 그런데 깃헙 데스크탑의 메뉴에 있는 'New repository...'로 폴더를 생성하면 선택한 폴더 아래에 하위폴더가 생성되고, 하위폴더가 새로운 레포지..
-
ttkbootstrapPython/이것저것 파이썬 2022. 12. 22. 18:31
https://ttkbootstrap.readthedocs.io/en/latest/themes/ Themes - ttkbootstrap Themes ttkbootstrap comes packaged with a LOT of beautifully styled light and dark themes, which you can view in a demo by typing this command into your terminal after installing ttkbootstrap. >>> python -m ttkbootstrap You will see a demo screen that look ttkbootstrap.readthedocs.io https://github.com/israel-dryer/ttkbo..
-
[파이썬] 웹 크롤러 + Tkinter : 기상청 일기예보Python/파이썬 웹 크롤러 2022. 12. 18. 22:11
https://www.weather.go.kr/w/pop/rss-guide.do RSS 서비스 안내 RSS(Really Simple Syndication, Rich Site Summary)란 블로그처럼 컨텐츠 업데이트가 자주 일어나는 웹사이트에서, 업데이트된 정보를 쉽게 구독자들에게 제공하기 위해 XML을 기초로 만들어진 데이터 형식입 www.weather.go.kr 아래 코드는 1.5시간에 1번씩 기상청 RSS를 크롤링해온다. 필요 이상의 과도한 크롤링은 서버 부담만 늘릴 뿐이다. 서울 강남 개포1동 RSS 주소 : https://www.kma.go.kr/wid/queryDFSRSS.jsp?zone=1168066000 import tkinter as tk import xml.etree.ElementTr..