pandas 读excel中的长数字时,即使excel中已经设置为文本,读进df后也会自动变成科学计数法。本篇博客介绍解决方法
源数据:
import pandas as pd
data_path = r"C:\Users\Haley\Desktop\order.xlsx"
data = pd.read_excel(data_path)
data.head()
结果:
解决方法:
import pandas as pd
data_path = r"C:\Users\Haley\Desktop\order.xlsx"
'''在读取时加上converter参数,先转成str再读'''
data = pd.read_excel(data_path, converters={'订单编号':str})
data.head()
更多推荐
【Python_023】解决pandas读excel中长数字变成科学计数法的问题
发布评论