행위

"Pandas 엑셀"의 두 판 사이의 차이

DB CAFE

(엑셀 읽기)
 
(같은 사용자의 중간 판 하나는 보이지 않습니다)
1번째 줄: 1번째 줄:
 
== pandas + 엑셀 파일 읽고 쓰기 ==
 
== pandas + 엑셀 파일 읽고 쓰기 ==
=== 엑셀 읽기 ===
+
 
 
* 파이썬 모듈 설치  
 
* 파이썬 모듈 설치  
 
<source lang=python>
 
<source lang=python>
7번째 줄: 7번째 줄:
 
pip install openpyxl  
 
pip install openpyxl  
 
</source>
 
</source>
 
+
=== 엑셀 읽기 ===
* 코드
 
 
<source lang=python>
 
<source lang=python>
 
import pandas as pd
 
import pandas as pd
16번째 줄: 15번째 줄:
 
print(df)
 
print(df)
 
</source>
 
</source>
+
 
 
=== 엑셀 쓰기 ===
 
=== 엑셀 쓰기 ===
 
<source lang=python>
 
<source lang=python>

2023년 7월 24일 (월) 17:23 기준 최신판

thumb_up 추천메뉴 바로가기


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)