pandas 이용하여 python에서 excel file의 data 다루기. [2018.09.12]
pandas라는 module이 필요.
import pandas #importing "pandas" module.
##loading dataframe from excel file
xls = pandas.ExcelFile('file path') #put the excel file whose name is "file path" into the variable "xls".
sheetname = xls.sheet_names #put the list of sheet names into the variable "sheetname"
df = pandas.read_excel ( xls, sheet number ) #variable df : dataframe of sheet number in the variable "xls"
##saving dataframe to excel file
xlsx = pandas.ExcelWriter('file path') #make excel writer 'xlsx' whose name is 'file path'
df.to_excel(xlsx, 'sheet name') #write the dataframe df to 'xlsx' with sheet name of 'sheet name'
xlsx.save() #save the excel file 'xlsx'
'Mathematica&Python' 카테고리의 다른 글
dict 형식 이용하여 변수명 자동 설정하기. [2018.09.13] (0) | 2018.09.13 |
---|---|
matplotlib.pyplot 이용하여 그래프 꾸미기 [2018.09.12] (0) | 2018.09.13 |
[2017.04.14] python 3.x버전에서 pip 사용법 (0) | 2017.04.14 |
[2017.04.14] linux mint 17.3에서 python3.5를 기본으로 바꾸기 (0) | 2017.04.14 |
[2017.04.10] Vpython 설치 (windows10) (0) | 2017.04.07 |