zoukankan      html  css  js  c++  java
  • 利用pandas将numpy数组导出生成excel

    代码

     1 # -*- coding: utf-8 -*-
     2 """
     3 Created on Sun Jun 18 20:57:34 2017
     4 
     5 @author: Bruce Lau
     6 """
     7 
     8 import numpy as np
     9 import pandas as pd
    10 
    11 # prepare for data
    12 data = np.arange(1,101).reshape((10,10))
    13 data_df = pd.DataFrame(data)
    14 
    15 # change the index and column name
    16 data_df.columns = ['A','B','C','D','E','F','G','H','I','J']
    17 data_df.index = ['a','b','c','d','e','f','g','h','i','j']
    18 
    19 # create and writer pd.DataFrame to excel
    20 writer = pd.ExcelWriter('Save_Excel.xlsx')
    21 data_df.to_excel(writer,'page_1',float_format='%.5f') # float_format 控制精度
    22 writer.save()

     转载:https://blog.csdn.net/qq_33039859/article/details/73440782

  • 相关阅读:
    java--保留重复排序
    java--TreeSet比较器排序
    java--去重练习
    java--HashSet
    java--集合可变参数
    spring MVC入门
    java IO详解
    spring入门
    redis详解
    maven教程
  • 原文地址:https://www.cnblogs.com/luozeng/p/8878289.html
Copyright © 2011-2022 走看看