[英]fixing improper ID formatting
Background : The following code works to export a pandas
df
as an excel
file: 背景 :以下代码可将
pandas
df
导出为excel
文件:
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
问题 :我的
excel
文件中的ID
列显示为8.96013E+17
而不是896013350764773376
I try to alter it in excel
using format
and zipcode
but it still gives the wrong ID
896013350764773000
我尝试使用
format
和zipcode
在excel
进行更改,但它仍给出错误的ID
896013350764773000
Question: Using excel
or python
code, how do I keep my original 896013350764773376
ID
format? 问题:使用
excel
或python
代码,如何保持原始的896013350764773376
ID
格式?
Excel uses IEEE754 doubles to represent numbers and they have 15 digits of precision. Excel使用IEEE754双精度来表示数字,并且精度为15位。 So you are not going to be able to represent an 18 digit id as a number in Excel.
因此,您将无法在Excel中将18位ID表示为数字。 You will need to convert it to a string to maintain all the digits.
您将需要将其转换为字符串以保留所有数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.