zoukankan      html  css  js  c++  java
  • 向excel中写入行,列

     1 import pandas
     2 #Series表示序列,可以表示行或者列
     3 
     4 d={'x':100,'y':300,'z':400}
     5 s1=pandas.Series(d)
     6 #print(s1.index)   #查看其中的索引
     7 
     8 s1=pandas.Series([1,2,3],index=[1,2,3],name='A')
     9 s2=pandas.Series([30,50,70],index=[1,2,3],name='B')
    10 s3=pandas.Series([20,70,59],index=[1,2,3],name='C')
    11 
    12 
    13 
    14 #把三个Series序列当做列
    15 df=pandas.DataFrame({s1.name:s1,s2.name:s2,s3.name:s3})
    16 print(df)
    17 
    18     A B   C
    19 1   1 30 20
    20 2   2 50 70
    21 3  3 70  59
    22 
    23 #把三个Series序列当做行
    24 df1=pandas.DataFrame([s1,s2,s3])
    25 print(df1)
    26 
    27   1   2  3
    28 A 1   2  3
    29 B 30 50 70
    30 C 20 70 59
  • 相关阅读:
    Grails
    Grails
    Grails
    Grails
    Grails
    Grails
    PG
    TopShelf安装多实例
    Js 实现自定义事件
    HttpContext未null处理
  • 原文地址:https://www.cnblogs.com/luckiness/p/13079867.html
Copyright © 2011-2022 走看看