Back-end Skill/Python

Python Pandas로 Excel 파일 불러오고 조회하는 방법

Sophie소피 2022. 7. 10. 03:21
import pandas as pd
import warnings
import os
warnings.simplefilter("ignore")

fileDir = "C:/Users/SEEYA/Desktop/Data/구급일지/" # 파일경로+ 폴더명
fileNm = "AAA.csv" # 파일 이름
data = pd.read_csv(fileDir + fileNm, encoding='CP949') 
selectdata = pd.DataFrame(data, columns = ['재난번호','구급보고서번호']) #조회할 컬럼 지정해서 출력하고 싶을 때 
print(selectdata)