# 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()