【发布时间】:2018-12-21 15:17:10
【问题描述】:
打印(数据框)
Total Price test_num
0 71.7 2.04256e+14
1 39.5 2.04254e+14
2 82.2 2.04188e+14
3 42.9 2.04171e+14
上传到 Mongo db 并将其转换为 Str 时出现错误。
打印(data_frame.astype(str))
Total Price test_num
0 71.7 204255705072224.0
1 39.5 204253951078915.0
2 82.2 204188075120577.0
3 42.9 204171098699772.0
将 Int 转换为 Str 时,在末尾添加 .0。 如何有效消除 .0? 谢谢
【问题讨论】:
-
df = df.apply(lambda x: x.replace('0.0', ""))
标签: python string python-3.x pandas dataframe