Home > Mobile >  I need to save a df to excel. First column has 15 digits so it is taking as scientific number; how t
I need to save a df to excel. First column has 15 digits so it is taking as scientific number; how t

Time:07-19

I have a to save a file to_excel But the fist column has 15 digits in it and in Excel is showing as 31100000 13 something in want this to show as number itself how do I do that.

writer = pd.ExcelWriter('test1.xlsx', engine = 'xlsxwriter')
df.to_excel(writer,'Sheet1')
workbook  = writer.book
worksheet = writer.sheets['Sheet1']
format1 = workbook.add_format({'num_format': '#'})
worksheet.set_column('A:A', 30, format1)
writer.save()

I tried this code problem is it's adding index and also it's not helping with the scientific number also enter image description here This is the output image and i want to change the RMA it should display all the number instead scientific number

CodePudding user response:

Modify:

df.to_excel(writer,'Sheet1')

by

df.to_excel(writer,'Sheet1', index=False)

This will remove index.

  • Related