# Encoding: utf-8 ''' author: yhwu version: 2021-04-19 function: numpy array write in the excel file ''' import numpy as np import pandas as pd # define a as the numpy array a = np.array([1, 2, 3]) # transform a to pandas DataFrame a_pd = pd.DataFrame(a) # create writer to write an excel file writer = pd.ExcelWriter('a.xlsx') # write in ro file, 'sheet1' is the page title, float_format is the accuracy of data a_pd.to_excel(writer, 'sheet1', float_format='%.6f') # save file writer.save() # close writer writer.close()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。