pandas operation excel

1. Multiple sheets

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

  • pd.read_excel() ⇒ read the first sheet of excel into a DataFrame
  • Using the ExcelFile object:

    xls = pd.ExcelFile('excel_file_path.xls')
    xls.sheet_names     # 获取各个 sheet 的名字
    sheet_df = xls.parse(0)
  • Tricks: Read the sheet into a dictionary, indexed by sheet name:

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325946169&siteId=291194637