Suppose you need to apply the same function to multiple columns in one DataFrame, one straight way is like this:
val newDF = oldDF.withColumn("colA", func("colA")).withColumn("colB", func("colB")).withColumn("colC", func("colC"))
If you want to save some type, you can try this:
- Use
select
with varargs including*
:
import spark.implicits._