利用pandas庫將numpy文件轉爲excel文件


# 直接上代碼
import numpy as np
import pandas as pd

title='file_name'  # 讀取的文件名
data=np.load(title+'.npy')  # 讀取numpy文件
data_df=pd.DataFrame(data)  # 利用pandas庫對數據進行格式轉換

# create and writer pd.DataFrame to excel
writer = pd.ExcelWriter(title+'.xlsx')  # 生成一個excel文件
data_df.to_excel(writer,'page_1')  # 數據寫入excel文件
writer.save()  # 保存excel文件

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章