score:1

Accepted answer

you can use concat_ws function to create a string from an array as

val finaldf = df.withcolumn("_2", concat_ws(",", $"_2"))
  .withcolumn("_4", concat_ws(",", $"_4"))
  .withcolumn("_6", concat_ws(",", $"_6"))

hope this helps!


Related Query

More Query from same tag