취뽀 기록

#열심히 살자 #취업 #공부

Python/[시각화] 5

[folium] 지도 시각화, 단계 구분도

# 라이브러리 불러오기 import folium # 서울 지도 만들기 seoul_map = folium.Map(location = [37.55, 126.98], zoom_start = 12) # 파일로 저장 seoul_map.save('./seoul_map.html') # 서울 지도 만들기 - 스타일 적용 seoul_map = folium.Map(location = [37.55, 126.98], zoom_start = 12, tiles = 'Stamen Toner') # 파일로 저장 seoul_map.save('./seoul_map.html') import pandas as pd # 데이터 불러오기 df = pd.read_excel('/content/drive/MyDrive/hana1/data/서울..

Python/[시각화] 2023.06.18

[seaborn] 시각화(산점도, 히스토그램, 히트맵, 비율 막대 그래프, 빈도 막대 그래프, 상자 그림, 바이올린 그림, 조인트 그림, 그리드 분할, pairplot)

# seaborn으로 시각화 # 그래프 객체 fig = plt.figure(figsize = (12, 5)) ax1 = fig.add_subplot(1, 2, 1) ax2 = fig.add_subplot(1, 2, 2) # 산점도 # 회귀선이 없는 산점도 sns.regplot(x = 'age', y = 'fare', # 변수 설정 data = titanic, # 데이터 설정 ax = ax1, # axe 객체 설정 = 위치 설정 fit_reg = False) # 회귀선이 있는 산점도 sns.regplot(x = 'age', y = 'fare', # 변수 설정 data = titanic, # 데이터 설정 ax = ax2, # axe 객체 설정 = 위치 설정 fit_reg = True) plt.show() s..

Python/[시각화] 2023.06.18

[matplotlib] 그래프 시각화(보조축, 2축 그래프, 히스토그램, 산점도)

# 라이브러리 불러오기 import pandas as pd import matplotlib.pyplot as plt # 데이터 불러오기 df = pd.read_excel('/content/drive/MyDrive/hana1/data/남북한발전전력량.xlsx', engine = 'openpyxl') # 북한 데이터 추출 df_north = df.iloc[5:] # 데이터 전처리 df_north = df_north.drop('전력량 (억㎾h)', axis = 1) df_north = df_north.set_index('발전 전력별') df_north = df_north.T # 전력 증감율 계산 df_north = df_north.rename(columns = {'합계':'총발전량..

Python/[시각화] 2023.06.18

[matplotlib] 그래프 시각화 2(선 그래프, 면적 그래프, 막대 그래프, 옵션 지정)

# 데이터 불러오기 df = pd.read_excel('/content/drive/MyDrive/hana1/data/시도별 전출입 인구수.xlsx', engine = 'openpyxl') # NaN 값 채우기 df = df.fillna(method = 'ffill') # 서울시(전출지)에서 다른 지역(전입지)으로 이동한 인구 데이터 # 불 인덱스(True)를 데이터 추출 b_ind = (df['전출지별'] == '서울특별시') & (df['전입지별'] != '서울특별시') df_seoul = df[b_ind] # 전출지별 열 삭제 df_seoul = df_seoul.drop('전출지별', axis = 1) # 열 이름 변경 df_seoul = df_seoul.rename({'전입..

Python/[시각화] 2023.06.18

[matplitlib] 그래프 시각화

선그래프 # 기본값 kind = 'line' df_new_t.plot() # 보통 x 축에 시간이 옴 막대그래프 수직막대그래프 df_new.plot(kind = 'bar') 수평막대그래프 # 수평 막대 그래프 df_new.plot(kind = 'barh') df_new_t.plot(kind = 'barh') 히스토그램 df_new_t.plot(kind = 'hist') 산점도 # 차중과 연비의 산점도 df.plot(kind = 'scatter', x = 'mpg', y = 'weight') 상자수염그림 df[['mpg', 'acceleration']].plot(kind = 'box') [시도별 전출입 인구수] 데이터 전처리 및 시각화 # 라이브러리 불러오기 import pandas as pd import..

Python/[시각화] 2023.06.16