Background : The following code works to export a pandas
df
as an excel
file:
import pandas as pd
import xlsxwriter
writer = pd.ExcelWriter('Excel_File.xlsx', engine='xlsxwriter')
df.to_excel(writer, sheet_name='Sheet1')
writer.save()
Problem : My ID
column in the excel
file shows up like 8.96013E+17
instead of 896013350764773376
I try to alter it in excel
using format
and zipcode
but it still gives the wrong ID
896013350764773000
Question: Using excel
or python
code, how do I keep my original 896013350764773376
ID
format?
Excel uses IEEE754 doubles to represent numbers and they have 15 digits of precision. So you are not going to be able to represent an 18 digit id as a number in Excel. You will need to convert it to a string to maintain all the digits.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.