zoukankan      html  css  js  c++  java
  • read_excel()

    1 主要是sheet_name的用法,不要少读了表.

    dirct = '../data/INSPEC_train/'
    # sheet_name 参数有两类四种情况
    # 第一类 list或None,返回一个字典,values都是Dataframe
    # 为list时,指定读取哪些表,字典的key是数字0,1,2等
    # 为None的时候返回所有的表,字典的key是表名,可以用a.keys()输出.
    # 第二类 int或string,返回Dataframe
    # header  指定作为列名的行,默认0,即取第一行.数据不含列名时,设置为None.
    a = pd.read_excel( dirct + 'Vp9AaLm_jQU91ppQU0S.xlsx', sheet_name='Process_Table')
    # a = pd.read_excel( dirct + 'Vp9AaLm_jQU91ppQU0S.xlsx', sheet_name=[0,1,2])
    print(type(a))
    print(a.keys())
    print(a)
    View Code

    2 合并表格

    dirct = '../data/INSPEC_train'
    dirList = []
    fileList = []
    files = os.listdir(dirct)
    dataProcess_Table=[]
    dataPhase_Table=[]
    dataParameters_Table=[]
    for i in tqdm(files):
        dirfile=dirct+"/"+i
        df_raw = pd.read_excel(dirfile, sheet_name='Process_Table')
        # 将每个Dataframe放入list后,存储
        dataProcess_Table.append(df_raw)
        df_raw = pd.read_excel(dirfile, sheet_name='Phase_Table')
        dataPhase_Table.append(df_raw)
        df_raw = pd.read_excel(dirfile, sheet_name='Parameters_Table')
        dataParameters_Table.append(df_raw)
    dataProcess_Table=pd.concat(dataProcess_Table)
    dataPhase_Table=pd.concat(dataPhase_Table)
    dataParameters_Table=pd.concat(dataParameters_Table)
    
    dataProcess_Table.to_csv('../data/dataProcess_Table.csv', index=False)
    dataPhase_Table.to_csv('../data/dataPhase_Table.csv', index=False)
    dataParameters_Table.to_csv('../data/dataParameters_Table.csv', index=False)
    View Code

    ttt

  • 相关阅读:
    e.target和e.event和event.srcElement
    js代码优化
    史上最全的CSS hack方式一览
    学习NodeJS第一天:node.js引言
    响应式布局
    HTML+CSS编写规范
    英文SEO外部链接资源收集之常用的footprints
    判别木马
    php简单命令代码集锦
    zencart 新页面调用好功能代码集:
  • 原文地址:https://www.cnblogs.com/xxswkl/p/12163934.html
Copyright © 2011-2022 走看看