首页 > 编程 > Python > 正文

利用pandas将numpy数组导出生成excel的实例

2020-02-15 21:52:26
字体:
来源:转载
供稿:网友

上图

代码

# -*- coding: utf-8 -*-"""Created on Sun Jun 18 20:57:34 2017@author: Bruce Lau"""import numpy as npimport pandas as pd# prepare for datadata = np.arange(1,101).reshape((10,10))data_df = pd.DataFrame(data)# change the index and column namedata_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 excelwriter = 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

以上这篇利用pandas将numpy数组导出生成excel的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林站长站。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表