利用pandas将numpy数组导出生成excel的实例
时间:2021-04-11 08:58:32|栏目:Python代码|点击: 次
上图

代码
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 18 20:57:34 2017
@author: Bruce Lau
"""
import numpy as np
import pandas as pd
# prepare for data
data = np.arange(1,101).reshape((10,10))
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()
How to move one row to the first in pandas?
create a new dataframe object use .reindex([...]) attribute/method
上一篇:Python用GET方法上传文件
栏 目:Python代码
下一篇:python GUI库图形界面开发之PyQt5树形结构控件QTreeWidget详细使用方法与实例
本文标题:利用pandas将numpy数组导出生成excel的实例
本文地址:http://www.codeinn.net/misctech/99284.html






