본문 바로가기

Python30

Pandas query 사용, 다중 조건, Like 검색 등 예제 Pandas Query¶ Query함수를 사용하여 데이터 조건식 적용 In [1]: import pandas as pd In [2]: # Set up data dataset_url= "https://archive.ics.uci.edu/ml/machine-learning-databases/car/car.data" df = pd.read_csv(dataset_url, names=['buying', 'maint', 'doors', 'persons', 'lug_boot', 'safety'], header=None) df.reset_index(drop=True, inplace=True) 데이터 출처 In [3]: df.head(5) Out[3]: buying maint doors persons lug_boot s.. 2022. 11. 9.
Notebook에서 matplotlib 한글 폰트 깨짐 문제 해결 Matplotlib 한글 폰트 깨짐 문제 확인 쥬피터 노트북에서 matplotlib으로 한글 출력 다음과 같이 깨져 보인다. 사용가능 폰트 리스트 확인 import matplotlib.font_manager as fm font_list = [f.name for f in fm.fontManager.ttflist] print(font_list) 📌 Windows, MacOs 의 설치 폰트가 다르므로, 위 폰트 리스트에 있는 폰트를 사용한다. Matplotlib 폰트 적용 import matplotlib.pyplot as plt # plt.rc('font', family='Malgun Gothic') # For windows plt.rc('font', family='AppleGothic') # For MacO.. 2022. 11. 2.
Python - pip install shap 오류 발생 시. MacBook환경에 shap 패키지 설치 중 의존성 오류 발생 시 해결방법. shap 패키지 설치 python -m pip install shap 다음의 오류 발생 ERROR: Failed building wheel for numba Running setup.py clean for numba Building wheel for llvmlite (setup.py) ... error ERROR: Command errored out with exit status 1: ... 중략 ... ERROR: Failed building wheel for llvmlite Running setup.py clean for llvmlite Successfully built shap Failed to build numba llv.. 2022. 9. 30.
Python with mysql8 - 데이터베이스 연결 및 예제 예제 환경 Mysql8 on docker Visual studio code MySql 도커 실행환경은 전 블로그 참고 2022.01.05 - [DevOps/Docker] - Docker - MySql 8 개발환경, docker-compose로 간단하게 구성하기 1. pymysql 설치 python 라이브러리로 mysql 접속 및 쿼리 기능을 제공한다. python3 -m pip install PyMySQL 예제 테이블 생성문 CREATE TABLE `student` ( `ID` mediumint NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL, `dob` char(8) DEFAULT NULL, `created_at` datetime DEFAULT NULL,.. 2022. 9. 3.