79102007

Date: 2024-10-18 12:09:44
Score: 0.5
Natty:
Report link

I have set columns from B to F like below:

with pd.ExcelWriter(r'C:\Users\Personal\output.xlsx') as writer:
        df.to_excel(writer, sheet_name='IBM_DATA', index=False)

        # below code use for column formatting
        wb = writer.book  # get workbook
        ws = writer.sheets['IBM_DATA']  # and worksheet

        # add a new format then apply it on right columns
        currency_fmt = wb.add_format({'num_format': '0.0000'})
        for col in range(1,5):
            ws.set_column(col,col,15, currency_fmt)

enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Shahidul Islam Molla