我有一个包含 500 万条记录的数据集,我需要使用提供多个或和条件来替换列中的所有值startsWith()。
此代码适用于单一条件:
df2.withColumn("Deposits", when(col("Deposits").startsWith("0"),"1.1").otherwise(col("Deposits"))).show()
Run Code Online (Sandbox Code Playgroud)
我需要这样做:
df2.withColumn("Deposits", when(col("Deposits").startsWith("0"||"1"),"1.1").otherwise(col("Deposits")))
Run Code Online (Sandbox Code Playgroud)