df.to_Excelの使い方
2677 ワード
DataFrame.to_excel(excel_writer, sheet_name='Sheet1', na_rep='',
float_format=None, columns=None, header=True, index=True,
index_label=None, startrow=0, startcol=0, engine=None,
merge_cells=True, encoding=None, inf_rep='inf', verbose=True,
freeze_panes=None)
共通パラメータの解析:
import numpy as np
import pandas as pd
from pandas import DataFrame
# IO
IO="C:\\Users\\zhouy_000\\Desktop\\python_study\\20190416\\test.xlsx"
IO_2="C:\\Users\\zhouy_000\\Desktop\\python_study\\20190416\\test_2.xlsx"
# excel
sheet_a=pd.read_excel(io=IO,sheet_name="abc",header=0)
print(sheet_a)
"""
0 23 1991-10-02
1 23 1992-11-02 NaN
2 25 1991-10-18
3 21 1989-09-09 NaN
4 25 1990-08-07 NaN
5 24 1991-12-12 NaN
6 26 1988-09-09
"""
sheet_a.to_excel(IO_2,sheet_name="abc_test1",na_rep="na_test",columns=[" "," "," "," "],index=False)
# na_rep bool , excel 0 1;
#columns : 。
#header : , 0, , ; , header = None
sheet_b=pd.read_excel(io=IO_2,sheet_name=0,header=0)
print(sheet_b)
"""
0 23 1991-10-02
1 23 1992-11-02 na_test
2 25 1991-10-18
3 21 1989-09-09 na_test
4 25 1990-08-07 na_test
5 24 1991-12-12 na_test
6 26 1988-09-09
"""
参照:https://blog.csdn.net/tongxinzhazha/article/details/78796952 以上、本人の学習過程を記録します.