"Pandas 엑셀"의 두 판 사이의 차이
DB CAFE
(새 문서: https://ponyozzang.tistory.com/618) |
(→엑셀 읽기) |
||
(같은 사용자의 중간 판 3개는 보이지 않습니다) | |||
1번째 줄: | 1번째 줄: | ||
− | + | == pandas + 엑셀 파일 읽고 쓰기 == | |
+ | |||
+ | * 파이썬 모듈 설치 | ||
+ | <source lang=python> | ||
+ | pip install pandas | ||
+ | pip install xlrd | ||
+ | pip install openpyxl | ||
+ | </source> | ||
+ | === 엑셀 읽기 === | ||
+ | <source lang=python> | ||
+ | import pandas as pd | ||
+ | |||
+ | df = pd.read_excel('test.xlsx', sheet_name="Sheet1", engine='openpyxl') | ||
+ | |||
+ | print(df) | ||
+ | </source> | ||
+ | |||
+ | === 엑셀 쓰기 === | ||
+ | <source lang=python> | ||
+ | import pandas as pd | ||
+ | |||
+ | df = pd.read_excel('test.xlsx', sheet_name="Sheet1", engine='openpyxl') | ||
+ | |||
+ | print(df) | ||
+ | |||
+ | df['전재산'] = df['전재산']/2 | ||
+ | |||
+ | print(df) | ||
+ | |||
+ | df.to_excel('test.xlsx', sheet_name="Sheet1", index=False) | ||
+ | </source> | ||
+ | [[category:Python]] |
2023년 7월 24일 (월) 17:23 기준 최신판
thumb_up 추천메뉴 바로가기
- DBA { Oracle DBA 명령어 > DBA 초급 과정 > DBA 고급 과정 }
- 튜닝 { 오라클 튜닝 목록 }
- 모델링 { 데이터 모델링 가이드 }
1 pandas + 엑셀 파일 읽고 쓰기[편집]
- 파이썬 모듈 설치
pip install pandas
pip install xlrd
pip install openpyxl
1.1 엑셀 읽기[편집]
import pandas as pd
df = pd.read_excel('test.xlsx', sheet_name="Sheet1", engine='openpyxl')
print(df)
1.2 엑셀 쓰기[편집]
import pandas as pd
df = pd.read_excel('test.xlsx', sheet_name="Sheet1", engine='openpyxl')
print(df)
df['전재산'] = df['전재산']/2
print(df)
df.to_excel('test.xlsx', sheet_name="Sheet1", index=False)