✔️ 모듈 사용

import pandas as pd
import matplotlib
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import font_manager as fm
from sqlalchemy import create_engine
import urllib.parse

✔️ 추가 설정

np.set_printoptions(precision=3)            # 소수점 3번째 자리에서 반올림
pd.set_option('display.max_rows', None)     # Row 생략없이 출력
pd.set_option('display.max_columns', None)  # Column 생략없이 출력
pd.set_option('display.max_colwidth', None) # 컬럼의 내용이 길어도 생략없이 출력
pd.set_option('display.width', None)
pd.set_option('display.float_format', '{:.5f}'.format) # 8.500000e+01 이런 형식의 지수표현을 하고 싶지 않을 경우

✔️ 엑셀파일 불러오기

# Jupyter Notebook이 실행중인 서버의 파일만 불러올 수 있습니다.
# 절대 경로를 입력합니다.
# Sheet 이름은 대소문자를 구분합니다.

df_user_calc = pd.read_excel(r'D:\6월\유저지표_20220708.xlsx', sheet_name='user_calc');

✔️ 엑셀파일 내보내기

# Jupyter Notebook이 설치된 서버에 파일이 저장됩니다.
# 인덱스 컬럼은 내보내지 않습니다.

UserData.to_excel(r'd:\UserData.xlsx', sheet_name='UserData', index=False)

✔️ 기존 엑셀 파일에 Sheet를 추가하여 내보내기

with pd.ExcelWriter(r'D:\user_data\2022_유저통계.xlsx', engine='openpyxl', mode='a') as writer:
    temp.to_excel(writer, sheet_name='2022_유저통계')

+ Recent posts