Dumping numpy array into an excel file

前端 未结 2 1202
感动是毒
感动是毒 2021-01-04 20:56

I am trying to dump numpy array into an excel file using savetxt method, but I am getting this weird error on the console:

.18e,%.18e,%.18e,%.18e,%.18e,%.18e         


        
2条回答
  •  臣服心动
    2021-01-04 21:46

    you could use pandas, its really easy friendly to use.

    import pandas as pd
    
    ## convert your array into a dataframe
    df = pd.DataFrame (array)
    
    ## save to xlsx file
    
    filepath = 'my_excel_file.xlsx'
    
    df.to_excel(filepath, index=False)
    

    hope it helps!

提交回复
热议问题