首页 > 其他 > 详细

pandas.read_excel()读取完整的数值型字符串

时间:2020-08-30 14:02:32      阅读:323      评论:0      收藏:0      [点我收藏+]

当pandas从excel文件中读取数值型字符串时,以0开始的字符串有可能将开始的0丢失,造成读取的字符串不完整,如在读取‘000001’时,得到的结果是’1‘。

技术分享图片

 

 

为了完整的读出整个字符串,在使用pd.read_excel时需要用到dtype这个参数:

rdSheet = pd.read_excel(‘tmp.xlsx‘, dtype = { ‘公司代码‘ : str })

0    000001
1    000002
2    000004
3    000005
4    000006
5    000007
6    000008
7    000009
8    000010

read_excel()详细参数请参考:

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_excel.html

pandas.read_excel()读取完整的数值型字符串

原文:https://www.cnblogs.com/yehaita/p/13584977.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!