판다스/함수 cheat sheet
[pandas] to_excel
김판다t
2022. 12. 30. 03:40
데이터 프레임이나 시리즈를 엑셀시트에 저장하는 함수
pandas to_excel
df.to_excel(excel_writer, sheet_name='Sheet1', index=True)
excel_writer (인수는 경로명 또는 ExcelWriter)
저장할 경로를 지정하는 인자. 하나의 시트에 저장할때는 저장할 파일경로명을 입력하고 다수의 시트에 저장할 때는 ExcelWriter를 이용한다.
sheet_name (인수는 문자열 / 기본값은 ‘Sheet1’)
데이터프레임을 저장할 시트의 시트명을 지정하는 인자
index (인수는 bool / 기본값은 True)
index를 저장할지 지정하는 인자. 파일을 불러올 때 RangeIndex를 붙여 데이터프레임을 불러오기에 RangeIndex를 저장할 필요는 없다. 주로 RangeIndex를 저장하고 싶지 않을 때 사용하게 되는 인자.
그외 많은 인자들이 있다. 더 궁금하면 아래 링크를 참고
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_excel.html