当前位置: 移动技术网 > IT编程>脚本编程>Python > 利用pandas将numpy数组导出生成excel的实例

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

2019年06月16日  | 移动技术网IT编程  | 我要评论

林郑月娥接受国务院任命,七龙珠第二部,耀舞长安粤语

上图

代码

# -*- 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

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网