for i in column_list:
    header = my_dataframe[[i]].astype(str).columns.values
header_len = len(header.max()) + 2
column_len = my_dataframe[[i]].astype(str).apply(lambda x: x.str.len()).max(
    ).max() + 2
if header_len >= column_len:
    worksheet.set_column(i, i, header_len)
else:
    worksheet.set_column(i, i, column_len)
writer.save()
Is there a way to auto-adjust Excel column widths with pandas.ExcelWriter?