Data Science
[판다스] 여러 엑셀 파일 합치기
태지쌤
2023. 1. 31. 20:00
반응형
pip install openpyxl
import pandas as pd
from glob import glob
from tqdm.notebook import tqdm
import os
# glob 함수를 이용해서 엑셀파일 목록을 가져옵니다.
stations_files = glob('./data/*.xls')
total = pd.DataFrame()
for file_name in stations_files:
temp = pd.read_excel(file_name, header = 2)
total = pd.concat([total, temp])
total = total.sort_values(by="지역")
total = total.reset_index(drop = True) # 기존 인덱스 날리기
total
total.to_excel("전체주유소.xlsx", index=False)
반응형