pandas 读取 电话号码 0 开头的 会有缺失值

公司的pandas 是python2 在执行读取的时候 ,电话号码开头 0 的 被自动删掉了,

input-data :

代码

 hive_clean_df=pd.read_csv(file_path,sep = '\t' )
hive_clean_df.to_csv("/result_hive_clean_df.csv", sep='\t', index=False,header=None)

输出:

很明显,我的0被系统判定为interger格式了,0就这样被干掉了。这时候加一个参数就行

 #hive_clean_df=pd.read_csv(file_path,sep = '\t',converters ={1:str} )

1代表默认的 列名称:

str 代表数据类型。这样就没问题了兄弟们!

解决了的话,点个赞谢谢啦!

猜你喜欢

转载自blog.csdn.net/Cincinnati_De/article/details/84109602