Python/Python 기초문법

Python - Pandas excel 파일 입출력 및 데이터 불러오기

GinaKim 2024. 1. 8. 18:29
728x90

파일 불러오기 & 파일 저장하기

파일 불러올 때, 인코딩 확인 !! 

df1 = pd.read_csv('data/sea_rain1_from_notepad.csv', encoding='cp949') #UTF8 
df1.to_excel("data/output.xlsx")

 

엑셀 파일에서 특정 시트 데이터 가져오는 법

df = pd.read_excel('data/학생시험성적.xlsx', sheet_name = '2차시험', index_col = '학생')
df

 

엑셀 파일에서 특정 열만 가져오는 법

 

air_quality_pm25 = pd.read_csv("air_quality_pm25_long.csv")
air_quality_pm25 = air_quality_pm25[["date.utc", "location", "parameter", "value"]]
air_quality_pm25.head()

 

728x90