python pandas read excel

python pandas read excel

Pandas库read_excel()参数详解

import pandas as pd
excelPath = r''
excelFile = pd.ExcelFile(excelName) # 加载excel文件
excelFile.sheet_names  # 获取工作表名称

for sheetName in excelFile.sheet_names:  # 遍历sheet
    #使用参数header去掉标题行 重新加载excel文件
    excelData = pd.read_excel(excelName, sheet_name=sheetName, header=1, na_values='null')
    #使用参数skiprows去掉标题行 重新加载excel文件
    excelData = pd.read_excel(excelName, sheet_name=sheetName, skiprows=[0], na_values='null')

    df = pd.DataFrame(excelData)
    
    for index, row in df.iterrows(): # 遍历行
        houseNum = row['房号']
        if type(houseNum) == float and isnan(houseNum):
            continue
        if type(houseNum) == str and 'youString' in houseNum:
            continue
发布了85 篇原创文章 · 获赞 27 · 访问量 16万+

猜你喜欢

转载自blog.csdn.net/qq_22038327/article/details/100582657