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

作者:GoAmterLiu 时间:2021-03-10 02:43:14 

上图

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

代码


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

来源:https://blog.csdn.net/qq_33039859/article/details/73440782

标签:pandas,numpy,excel
0
投稿

猜你喜欢

  • 超强多功能php绿色集成环境详解

    2023-07-15 01:07:22
  • TensorFlow固化模型的实现操作

    2022-09-12 22:28:42
  • python+selenium实现京东自动登录及秒杀功能

    2021-02-08 13:31:41
  • python基础教程之csv格式文件的写入与读取

    2021-05-24 09:20:12
  • python return实现汇率转换器教程示例

    2023-11-10 12:39:50
  • CSS3 + HTML5 实现未来 Web 设计

    2010-01-25 12:17:00
  • 精简高效的CSS命名准则和方法

    2010-09-17 18:38:00
  • Python面向对象程序设计示例小结

    2023-08-24 13:31:24
  • Python jiaba库的使用详解

    2022-05-11 22:20:46
  • python logging日志模块的详解

    2021-04-27 19:16:55
  • python自动化测试无法启动谷歌浏览器问题

    2021-01-08 21:35:54
  • 删除PHP数组中的重复元素的实现代码

    2023-06-06 21:19:46
  • 介绍Python中几个常用的类方法

    2023-02-10 09:17:49
  • python logging模块的分文件存放详析

    2023-04-02 20:27:32
  • python安装教程 Pycharm安装详细教程

    2022-08-08 02:25:55
  • python中实现数组和列表读取一列的方法

    2021-04-07 08:04:48
  • Python 添加命令行参数步骤

    2022-10-24 05:15:40
  • 简单介绍Python的Tornado框架中的协程异步实现原理

    2021-06-21 10:00:23
  • 查看ASP详细错误提示信息的图文设置方法

    2011-02-05 11:02:00
  • 解决django服务器重启端口被占用的问题

    2023-11-10 14:14:12
  • asp之家 网络编程 m.aspxhome.com