利用pandas将numpy数组导出生成excel

利用pandas将numpy数组导出生成excel

代码

 # -*- coding: utf- -*-
"""
Created on Sun Jun :: @author: Bruce Lau
""" import numpy as np
import pandas as pd # prepare for data
data = np.arange(,).reshape((,))
data_df = pd.DataFrame(data) # change the index and column name
data_df.columns = ['A','B','C','D','E','F','G','H','I','J']
data_df.index = ['a','b','c','d','e','f','g','h','i','j'] # create and writer pd.DataFrame to excel
writer = pd.ExcelWriter('Save_Excel.xlsx')
data_df.to_excel(writer,'page_1',float_format='%.5f') # float_format 控制精度
writer.save()

转载:https://blog.csdn.net/qq_33039859/article/details/73440782

上一篇:sublime text3如何在浏览器预览?


下一篇:Ubuntu中基于QT的系统网线连接状态的实时监视