20200720-Python的Pandas和NumPy保存到Excel

import numpy as np
import pandas as pd


#准备数据
data = np.arange(1,51).reshape((10,5))
data_df = pd.DataFrame(data)

#修改索引名和列名
data_df.columns = ['编号','姓名','学号','班级','岗位']
data_df.index = ['A','B','C','D','E','F','G','F','G','H']

#将dataframe写到excel
writer = pd.ExcelWriter('Save_Excel.xlsx')
data_df.to_excel(writer,'Pagee')
writer.save()

20200720-Python的Pandas和NumPy保存到Excel_第1张图片

你可能感兴趣的:(python)