简体   繁体   English

修复ID格式错误

[英]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 我尝试使用formatzipcodeexcel进行更改,但它仍给出错误的ID 896013350764773000

Question: Using excel or python code, how do I keep my original 896013350764773376 ID format? 问题:使用excelpython代码,如何保持原始的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.

相关问题 日期格式不正确,有时间 - Improper date formatting, with time 修复字符串格式的正确 alignment - Fixing right alignment of string formatting 数据格式不正确 - 将查询从 BigQuery 保存到 GCS - improper data formatting - saving query from BigQuery to GCS 修复 Python 散景日期时间导入格式 - Fixing Python Bokeh Datetime Import Formatting 在Python中为命令行上的错误用户ID创建异常 - Creating an Exception in Python for improper user id on command line 使用诱变剂修复ID3标签的编码 - Fixing encoding of ID3 tags with mutagen 在 Python PostgreSQL 代码中获取“TypeError:并非所有参数都在字符串格式化期间转换”(其他答案未修复) - Getting 'TypeError: not all arguments converted during string formatting' in Python PostgreSQL code (other answers not fixing it) 修复我的名称格式大写规则的实现(例如McStuff) - Fixing my implementation of capitalization rule for name formatting (e.g. McStuff) 在 Django (Django 3.0) 中将现有 id 转换为 uuid 后修复错误“格式错误的十六进制 UUID 字符串” - Fixing error “Badly formed hexadecimal UUID string” after converting existing id to uuid in Django (Django 3.0) 在python中进行不正确的数据测试 - Improper data testing in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM