170618 如何利用pandas将numpy数组导出生成excel

来源:互联网 发布:手机淘宝上的积分在哪 编辑:程序博客网 时间:2024/06/06 15:45

上图
这里写图片描述

代码

# -*- 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
原创粉丝点击