pandas 操作 excel

1. 多重 sheet

Using Pandas to pd.read_excel() for multiple worksheets of the same workbook

  • pd.read_excel() ⇒ 将 excel 的第一个 sheet 读取到 DataFrame
  • 使用 ExcelFile 对象:

    xls = pd.ExcelFile('excel_file_path.xls')
    xls.sheet_names     # 获取各个 sheet 的名字
    sheet_df = xls.parse(0)
  • Tricks:将 sheet 读入到字典中,通过 sheet 名索引:

    sheet_map = {}
    for sheet_name in xls.sheet_names:
        sheet_map[sheet_name] = xls.parse(sheet_name)

猜你喜欢

转载自blog.csdn.net/lanchunhui/article/details/80100555