Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I need to save a df to excel. First column has 15 digits so it is taking as scientific number; how to avoid that

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Modify:

df.to_excel(writer,'Sheet1')

by

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

This will remove index.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading