worksheet = writer.sheets['Sheet1']
format1 = workbook.add_format({'num_format': '#,##0.00'})
format2 = workbook.add_format({'num_format': '0%'})
format3 = workbook.add_format({'num_format': 'h:mm:ss AM/PM'})
worksheet.set_column('B:B', 18, format1)
worksheet.set_column('C:C', None, format2)
worksheet.set_column('D:D', 16, format3)
writer.save()
Writing pandas DataFrame to Excel with different formats for different columns