공공데이터를 분석해보다가 계속 사용하거나 헷갈리는 코드를 작성해보고자 한다.
- 항목별로 개수 그래프 생성
graph = pd.value_counts(df['column 이름'].values, sort=True)
graph.plot.bar()
graph.plot.bar(grid=True, figsize=(10, 8), fontsize=15)
- column 속 내가 원하는 것 데이터 가져오기
d2[d2["소재지지번주소"].str.contains("000읍")]
- 원하는 columns 가져와 dataframe 만들기
light = pd.DataFrame(d2, columns=['소재지도로명주소', '소재지지번주소', '카메라대수', '위도', '경도', '데이터기준일자'])
light
- plot 그릴 때 한글 깨짐 !! 하기
import matplotlib.pyplot as plt
from matplotlib import font_manager, rc
font_path = "C:/Windows/Fonts/NGULIM.TTF"
font = font_manager.FontProperties(fname=font_path).get_name()
rc('font', family=font)
'Python > python# 공부' 카테고리의 다른 글
| Python# 공부1 (0) | 2021.03.27 |
|---|
댓글