Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- python #pandas #data_preprocessing #data_process
- pandas #python #date #datetime
- ngrok
- mnist
- 파이썬
- SQL #PostgreSQL
- pandas #ewma #python #지수이동가중평균 #파이썬 #판다스 #ema #ewm
- aiohttp
- MachineLearning
- tf.where
- 선형회귀
- SQL #python #MySQL #PostgreSQL
- pandas #python #excel #판다스 #파이썬 #엑셀저장 #xlsxwriter
- Python
- 깃
- AI #RNN #LSTM #LSTMP #인공지능 #언어학습 #순차학습
- TensorFlow
- 비동기모듈
- REST_API
- git
- version_error
- 깃허브
- AI #Inductive_Bias #Relational_inductive_bias
- 판다스 #Pandas #DataFrame #Statistics #통계 #파이썬 #Python #Resample
- tensorflow #tensorflow-gpu #python #ubuntu #텐서플로우
- fashionmnist
- 특정값지우기
- 시계열데이터
- Asyncio
- Github
Archives
- Today
- Total
린스토리
[Pandas] Excel로 저장하기 (시트 여러개로 나눠서 저장하기) 본문
Pandas로 만든 DataFrame을 Excel로 저장하는 법을 알아보자.
근데 만들다보면 DataFrame이 여러개 생길 수 있고, 이걸 한 파일 내로 시트를 나눠 저장하고 싶을 때가 있다.
어떻게 하는지 알아보자!
Pandas 모듈은 설치되어 있겠지만, 만약 'xlsxwriter' 모듈이 설치되어 있지 않다면 설치해주도록 하자.
pip install xlsxwriter
or
conda install -c conda-forge xlsxwriter
이제 pandas dataframe이 있는 코드로 가서, 다음과 같이 해본다.
# 1. excel writer 선언
writer = pd.ExcelWriter('./test.xlsx', engine='xlsxwriter')
# 2. dataframe을 excel로 저장
df1.to_excel(writer, sheet_name='test1')
df2.to_excel(writer, sheet_name='test2')
# 3. excel 파일 저장하기
writer.save()
이렇게 하면 test.xlsx 파일 내에 'test1'과 'test2' 시트가 생기고 각각에 df1, df2 데이터프레임이 저장된 것을 볼 수 있다.
'Python > Pandas' 카테고리의 다른 글
| [Pandas] EWMA 적용하기 (0) | 2022.06.30 |
|---|---|
| [Pandas] 월별/주별/일별 데이터 통계내기 (Resample) (0) | 2022.06.28 |
| [Pandas] 날짜 생성하기 & 연산하기 (0) | 2022.06.19 |
| [Pandas] 조건 해당 값 변경 (0) | 2022.06.18 |
| [Pandas] DataFrame 생성 (0) | 2022.06.17 |
Comments