Now we'll save multiple sheets to one (the same) Excel file using Python pandas Just a reminder df stands for dataframe, and pd is short for pandas We'll still use the dfto_excel () method, but we'll need help from another class pdExcelWriter () As its name suggests, this class writes to Excel Once after creating headers, we write data into each row of the sheet import xlwt EXCEL_FILES_FOLDER = 'excel_files/' workbook = xlwtWorkbook() worksheet = workbookadd_sheet('Student') excel_file_path = EXCEL_FILES_FOLDER'write_excelxlsx' addDataToSheet(worksheet) workbooksave(excel_file_path) def addDataToSheet(worksheet) # first row worksheetwrite(1, 0, "01") worksheetwrite(1, 1, "James") worksheetwrite(1, 2, "Computer") worksheetwrite(1, 3, "A") # Second row worksheet>>> workbookget_sheet_names() Its better to see the sheet names in our workbook Python provides us the number of sheets with their names without any objection as 'Sheet1', 'Sheet2', 'Sheet3' Up to here, we have loaded an Excel file in memory and checked its sheets Now we refer to the particular sheet we want to delete in this Excel Workbook
Tutorial Python Excel The Definitive Guide Datacamp