且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将前导零添加到 Spark 数据帧中的列

更新时间:2023-11-18 21:08:40

你可以简单地使用 concat 内置函数来做到这一点

You can simply do that by using concat inbuilt function

df.withColumn("iD", concat(lit("00"), col("iD")))
           .withColumn("val", concat(lit("0"), col("val")))